-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
I have a GET action method like this in dropwizard framework:
@Path("/{id}")
@GET
public Response getFoo(@ApiParam(value = "Foo Id", required = true) @PathParam("id") IntParam id) {
...
}
IntParam is a dropwizard helper class that encapsulates the parameter type parser, so if user provides a value that can't be converted to integer for the id, Bad Request (400) response will be returned.
The problem by using this IntParam class is swagger will generate the parameter type in swagger.json as a string rather than integer since IntParam class is not understandable by the swagger parser.
"parameters" : [ {
"name" : "id",
"in" : "path",
"description" : "Foo Id",
"required" : true,
"type" : "string"
} ],
I could change the type of id to int/Integer in the action method but I will lose the benefit of IntParam.
So my suggestion is to add new parameter for @ApiParam that let developer to set or override the parameter type, maybe something like dataType parameter in @ApiImplicitParam.
@Path("/{id}")
@GET
public Response getFoo(@ApiParam(value = "Foo Id", required = true, dataType = "int") @PathParam("id") IntParam id) {
...
}
Metadata
Metadata
Assignees
Labels
No labels