Swagger 或 springfox 忽略 Pageable 参数
Swagger or springfox ignore Pageable param
我正在尝试使用 springfox 构建 swagger 文档。
我的休息方式是
@RequestMapping(value = "/filter", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public final Page<SomeOtherObj> filter(@RequestBody SomeObj dto, Pageable pageable) {...}
在输出中我有参数列表的文档:
"parameters": [
{
"in": "body",
"name": "dto",
"description": "dto",
"required": true,
"schema": {
"$ref": "#/definitions/SomeOdj"
}
}
],
Pageable 在哪里?为什么它大摇大摆地忽略了?
我的猜测是因为它没有用 @RequestBody
标记,所以它被忽略了。不管怎样,你可以用 @ApiParam
注释隐式标记它。它应该包含在最终规范中。
@RequestMapping(value = "/filter", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public final Page<SomeOtherObj> filter(@RequestBody SomeObj dto, @ApiParam(name = "Pageable filter", required = false) Pageable pageable) {...}
更新
根据评论
Issues happens in v 2.8.0
. Everything is OK in new version 2.9.0
of Springfox Swagger. And it works fine in older versions (I tried
2.6.1
)
我正在尝试使用 springfox 构建 swagger 文档。
我的休息方式是
@RequestMapping(value = "/filter", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public final Page<SomeOtherObj> filter(@RequestBody SomeObj dto, Pageable pageable) {...}
在输出中我有参数列表的文档:
"parameters": [
{
"in": "body",
"name": "dto",
"description": "dto",
"required": true,
"schema": {
"$ref": "#/definitions/SomeOdj"
}
}
],
Pageable 在哪里?为什么它大摇大摆地忽略了?
我的猜测是因为它没有用 @RequestBody
标记,所以它被忽略了。不管怎样,你可以用 @ApiParam
注释隐式标记它。它应该包含在最终规范中。
@RequestMapping(value = "/filter", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public final Page<SomeOtherObj> filter(@RequestBody SomeObj dto, @ApiParam(name = "Pageable filter", required = false) Pageable pageable) {...}
更新
根据评论
Issues happens in v
2.8.0
. Everything is OK in new version2.9.0
of Springfox Swagger. And it works fine in older versions (I tried2.6.1
)