Sort API methods in Swagger-UI

后端 未结 5 1301
故里飘歌
故里飘歌 2020-12-09 09:37

I cannot find any working example, how to achieve the following: I want my API methods in the Swagger-UI sorted either by methods (GET-POST-PUT-DELETE) OR/AND alphabetically

5条回答
  •  执笔经年
    2020-12-09 10:02

    Update for Swagger 3.18.3

     window.ui = SwaggerUIBundle({
               ...
                operationsSorter: function (a, b) {
                    var order = {'get': '0', 'post': '1', 'put': '2', 'delete': '3'};
                    return order[a.get("method")].localeCompare(order[b.get("method")]);
                },
               ...
     });
    

提交回复
热议问题