【发布时间】:2016-01-27 10:04:47
【问题描述】:
我正在使用Springfox 库为 REST 服务生成文档并将其显示在 Swagger UI 中。我按照Springfox documentation 中的指示进行操作。
我有一个控制器,它使用查询字符串中的参数,方法映射如下:
@ApiOperation(value = "")
@RequestMapping(method = GET, value = "/customcollection/{id}/data")
public Iterable<CustomeType> getData(@ApiParam(value = "The identifier of the time series.")
@PathVariable String id,
@ApiParam(name = "startDate", value = "start date", defaultValue = "")
@RequestParam("startDate") String startDate,
@ApiParam(name = "endDate", value = "end date", defaultValue = "")
@RequestParam("endDate") String endDate)
然后在 swagger-ui 中生成的映射器显示为:
GET /customcollection/{id}/data{?startDate,endDate}
但是当我点击 Try it Out 时,请求的 URL 是错误的:
http://localhost:8080/customcollection/1/data{?startDate,endDate}?startDate=1&endDate=2
如何解决?
【问题讨论】:
标签: spring-boot swagger-ui swagger-2.0 springfox