按字母顺序订购SpringDoc操作参数
从Springfox迁移-Springdoc
Springfox生成了一个OpenAPI定义,该定义以字母顺序排序所有参数,我已迁移到SpringDoc,但无法找到一种方法来保留参数的Springfox排序(Alpha),例如
,例如控制器:
getPerson(name, address, mobile)
SpringFox生成的OpenAPI定义:
getPersonService(address, mobile, name)
SpringDoc生成的OpenAPI定义:
getPersonService(name, address, mobile)
有属性可以订购生成的定义的其他方面,
springdoc.swagger-ui.operationsSorter=method
springdoc.swagger-ui.tagsSorter=alpha
springdoc.writer-with-order-by-keys: true
我找不到 :属性要订购操作参数,是否有设置可以实现此目的?还是可以干净地实现: openapicustomiser
或操作customizer
Migrating from springfox - springdoc
springfox generated an openApi definition that ordered all the parameters in alphabetical order, I've migrated to springdoc, but have been unable to find a way to keep the springfox ordering(alpha) of the parameters, e.g.
Controller:
getPerson(name, address, mobile)
springfox generated openApi definition:
getPersonService(address, mobile, name)
springdoc generated openApi definition:
getPersonService(name, address, mobile)
There are properties to order other aspects of the generated definition with:
springdoc.swagger-ui.operationsSorter=method
springdoc.swagger-ui.tagsSorter=alpha
springdoc.writer-with-order-by-keys: true
I have been unable to find a property to order the operation parameters, is there a setting to accomplish this? or can it be achieved cleanly with:OpenApiCustomiser
or OperationCustomizer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一种使用
操作customizer
(kotlin语法)的解决方案:如果您使用分组API,请不要忘记还可以通过
.addoperationCustomizer(parameterOrderCustomizer())添加它们
Here's a solution using the
OperationCustomizer
(Kotlin Syntax):and in case youre using grouped apis, dont forget to also add them to the groups via
.addOperationCustomizer(parameterOrderCustomizer())
更新您的application.property文件:
或在application.yaml文件
路径,架构和属性上排序字母上的升序完美地很好地排序
Update your application.property file with:
or in application.yaml file
Paths, schemas and properties is sorted ascending alphabetically perfectly fine