Closed bogdatov closed 9 years ago
Which version of swagger-core do you use?
It shouldn't recognize page
and size
as body parameters in any case, so that's a bug.
However, it is not clear what output you get when you add @ApiParam
to those parameters. It doesn't have a way to set the type as that's inferred from the actual type of the parameter.
@bogdatov I wonder how do you get path
for loginId
. @PathVariable
annotation is the SpringFramework annotation and it's not processed by swagger-core.
I would expect to get these types for your parameters
loginId
is body
page
and size
are both query
Do you have some custom SwaggerExtension
for handling @PathVariable
?
@webron I use this in Maven ( and spring boot, if it makes a difference )
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.0.0</version>
</dependency>
My Swagger config uses this:
@Profile({"development","dit","sit","uat","production"})
@Configuration
@EnableSwagger2
public class SwaggerConfig {
My code WITH @ApiParam look like this:
@RequestMapping(value = "v1/um/user/search/{loginId}", method = RequestMethod.GET, produces = "application/json")
@PerformanceMetrics(sla = 500)
@ApiOperation(value = "Returns user list", notes = "Returns list of trails matching the critera. SLA:500", response = List.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successful retrieval of list of users matching the search criteria", response = SecUserDTO.class),
@ApiResponse(code = 400, message = "Invalid input provided"),
@ApiResponse(code = 404, message = "No matching user found") })
public List<SecUserDTO> searchUsers(
@PathVariable String loginId,
@ApiParam(name="page", value="start page") @QueryParam("page") @DefaultValue("1") Integer page,
@ApiParam(name="page", value="page size" ) @QueryParam("size") @DefaultValue("500") Integer size,
HttpServletRequest request)
throws InterruptedException, ExecutionException, TimeoutException, BindException {
And my swagger-ui.html looks like this:
@bogdatov - if you're using springfox, this has nothing to do with swagger-core. They use the same annotations but that's pretty much it. All the processing is done by them. You'd need to open an issue on their repository looking for assistance as this is unfortunately beyond the scope of this project.
Thanks, opened with springfox
When in Swagger 2 I have this
All 3 parameters show up in Swagger UI. But I see "Parameter Type" for "page" and for "size" as "body", not "query" For "loginId" I see "Parameter Type" as "path"
And since I cant use "parameterType" as part of @ApiParam, what is happening is that when testing from SwaggerUI, both "page" and "size" parameters come into searchUsers as "null" even if I specify values in Swagger UI.
But when I test with e.g. SoapUI - everything works as expected.