|
|
好帅的沙发 · 如何为 Python 应用选择最好的 ...· 9 月前 · |
|
|
唠叨的卡布奇诺 · 高雄醫學大學 研究發展處 - ...· 1 年前 · |
|
|
空虚的南瓜 · 动手学Avalonia:基于Semantic ...· 1 年前 · |
|
|
满身肌肉的野马 · 一图了解es6常用数据迭代函数map,fil ...· 1 年前 · |
|
|
魁梧的拖把 · 【Python 库】requests ...· 1 年前 · |
如何按字母顺序对我的操作进行排序,例如、 GET 、 POST 、 PUT 。
我读过这篇文章,但它是用HTML写的,但在我的例子中,我已经将Swagger集成到Spring中,所以我需要在创建一个文档时对它进行排序。
然后,我在文档中注意到了这个方法
operationOrdering()
,但是我仍然无法使它工作。
发布于 2018-10-11 13:01:33
我使用Springfox版本2.8.0,下面的代码片段适用于我的文档API:
@Bean
UiConfiguration uiConfig() {
return UiConfigurationBuilder
.builder()
.operationsSorter(OperationsSorter.METHOD)
.build();
}
有两个可能的值:
OperationsSorter.ALPHA
-按
路径
按字母顺序排序API端点
OperationsSorter.METHOD
-用
方法
按字母顺序排序API端点
OperationsSorter.METHOD
是你要找的东西。
使用
替代
使用
operationOrdering()
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.operationOrdering(new Ordering<Operation>() {
@Override
public int compare(Operation left, Operation right) {
return left.getMethod().name().compareTo(right.getMethod().name());
}
但是,由于Springfox中的一个bug似乎仍然是活动的( 操作顺序不起作用 ),所以这是行不通的。
发布于 2021-03-14 17:28:36
使用 application.properties 中的 Spring 2.4 和 OpenAPI ,可能会对以下属性感兴趣:
发布于 2020-02-07 09:35:20
@Bean