Skip to content

Query Param Bugs #81

@kevind-wgu

Description

@kevind-wgu

I was looking into avaje-http for javalin to see how it worked and ran across a few issues I thought I would mention.

    @Get("/{id}")
    public Job get(Integer id, @QueryParam("p1") String p1, @QueryParam("p2") Double p2, @QueryParam("p3") Integer p3, @QueryParam("p4") Float p4, String body) {
        return crudService.getRequired(id);
    }

produces this code

    ApiBuilder.get("/job/{id}", ctx -> {
      ctx.status(200);
      Integer id = asInteger(ctx.pathParam("id"));
      String p1 = ctx.queryParam("p1");
      Double p2 = ctx.bodyAsClass(Double.class);
      Integer p3 = toInteger(ctx.queryParam("p3"));
      Float p4 = toFloat(ctx.queryParam("p4"));
      String body = ctx.queryParam("body");
      // no validation required on p2
      ctx.json(controller.get(id, p1, p2, p3, p4, body));
    });

"p2" is being read via bodyAsClass rather than as a query param.
"p4" is being loaded with toFloat but the toFloat method doesn't exist. I am guessing it is supposed to be calling asFloat.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions