[Suggestion] New parameter on @ApiParam to specify parameter type
See original GitHub issueI 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) {
...
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to make SpringFox Swagger render a string parameter ...
Try to override String param as @ApiParam(hidden = true) and add new param for your object: @ApiImplicitParams({ @ApiImplicitParam(name ...
Read more >Swagger @ApiParam vs @ApiModelProperty - Baeldung
The @ApiParam annotation helps to specify the name, type, description (value), and example value of the parameter. Moreover, we can specify ...
Read more >Documenting and Trying Out Matrix Type Parameters
Has anyone tried documenting and then "trying out" matrix type parameters with Swagger? Documenting seems to be fine (apart from label not being...
Read more >ApiParam (swagger-annotations 1.5.0 API)
Annotation Type ApiParam ... Specifies whether the parameter can accept multiple values by having ... Specifies if the parameter is required or not....
Read more >Springfox Reference Documentation - GitHub Pages
Alternatively you could set the following gradle/project properties (-Pproperty) ... ParameterType; import springfox.documentation.service.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks. The documentation needs to be improved, like the explanation of the
type
field should provide the list of possible values. When I tried thetype
, I have to guess what is the correct value for the integer parameter. I tried set it to"Integer"
at first, it didn’t work, then tried"int"
, it didn’t work too, then finally got the correct value which is"integer"
(all lower case).PRs are welcome.