I'm using Docket to configure my Swagger 2 instance. But the only Options I currently see are to sort by Type (POST, GET, etc.) or by endpoint name (a-z).
There is a logical order to my endpoints and I'd like to display them in that order
POST /start
POST /uplaod
POST /finalize
POST /checkStatus
POST /checkStatus
POST /finalize
POST /start
POST /upload
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.host(swaggerHost)
.pathProvider(new RelativePathProvider(servletContext) {
@Override
public String getApplicationBasePath() {
return swaggerBasePath;
}
})
.select()
.apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
.build()
.apiInfo(apiInfo())
.securitySchemes(Collections.singletonList(securitySchema()))
.securityContexts(Collections.singletonList(securityContext()));
}
Sorting operations in Swagger UI - Sort by specific http verb order, then by path
operationsSorter: function (a, b) {
const order = {
'get': '0', 'post': '1', 'patch': '2', 'put': '3', 'delete': '4',
'head': '5', 'options': '6', 'connect': '7', 'trace': '8'
};
return (
order[a.get("method")].localeCompare(order[b.get("method")])
|| a.get("path").localeCompare(b.get("path"))
);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With