gpt4 book ai didi

java - Swagger 或 springfox 忽略 Pageable 参数

转载 作者:行者123 更新时间:2023-11-30 10:14:56 25 4
gpt4 key购买 nike

我正在尝试使用 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 在哪里?为什么它 Swagger 忽略了?

最佳答案

我的猜测是因为它没有用 @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)

关于java - Swagger 或 springfox 忽略 Pageable 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50723006/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com