问题
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"
})
Can any one tell the best way to change the order of the API methods.
回答1:
Swagger UI 3.0.7 added support for 2.x's operationsSorter
parameter that controls method sorting inside each API/tag.
operationsSorter
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"
})
The apisSorter
parameter is not yet supported in 3.x.
来源:https://stackoverflow.com/questions/42977003/api-methods-sorting-swagger-version-3-0-2