API 方法排序:Swagger 3.0.2 版 [英] API methods Sorting : Swagger version 3.0.2
问题描述
我正在使用 swagger version 3.0.2 ,我也遵循了 这个答案 但对方法顺序没有影响.
I am using swagger version 3.0.2 , I have also followed this answer but there was no effect on the method order.
window.onload = function() {
const ui = SwaggerUIBundle({
.....
apisSorter: "alpha",
layout: "StandaloneLayout"
})
谁能说出改变 API 方法顺序的最佳方法.
Can any one tell the best way to change the order of the API methods.
推荐答案
Swagger UI 3.0.7 添加了对 2.x 的 operationsSorter
参数的支持,该参数控制每个 API/标签内的方法排序.
Swagger UI 3.0.7 added support for 2.x's operationsSorter
parameter that controls method sorting inside each API/tag.
操作排序器
对每个API的操作列表进行排序.它可以是alpha"(按字母数字路径排序)、method"(按 HTTP 方法排序)或函数(请参阅 Array.prototype.sort() 以了解排序函数的工作原理).默认为服务器返回的顺序不变.
Apply a sort to the operation list of each API. It can be 'alpha' (sort by paths alphanumerically), 'method' (sort by HTTP method) or a function (see Array.prototype.sort() to know how sort function works). Default is the order returned by the server unchanged.
const ui = SwaggerUIBundle({
url: "http://petstore.swagger.io/v2/swagger.json",
...
operationsSorter: "alpha"
})
3.x 尚不支持 apisSorter
参数.
The apisSorter
parameter is not yet supported in 3.x.
这篇关于API 方法排序:Swagger 3.0.2 版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!