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
What I want:
POST /start
POST /uplaod
POST /finalize
POST /checkStatus
Instead I get something like this:
POST /checkStatus
POST /finalize
POST /start
POST /upload
Code:
@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()));
}
operationOrdering()
to manually order – Waltnerpublic int compare(Operation left, Operation right)
method. It's similar to implementing a sort order with thecompareTo
ofComparable
– Waltnerleft.methodNameHere()
would have that info? – Poachy