I have a GET method in Controller that takes as one of a parameters (@PathVariable) an Enum. This Enum has several values and when it is being generated by Swagger/OpenApi, in the Swagger UI when testing/try out the endpoint, list of possible parameter values coming from Enum, is displayed. However it is being displayed in the order in which values are typed in Enum. I would like to order the list alphabetically, to be displayed in Swagger UI. I cannot simply sort the Enum as it is coming from external library.
@GetMapping("/{id}/status/{enumStatus}/validate")
public ResponseEntity<RootElement> getMethod(@PathVariable("id") final String id, @PathVariable("status") final StatusEnum enumStatus) {
return myRestService.validate(id, enumStatus);
}
private enum StatusEnum {
B_STATUS, A_STATUS, NO_STATUS, CC_STATUS
}
I was hoping for something similar but I was not able to get specific PathVariable: How do I write a custom sorter to sort my springdoc swagger tags by name in the UI?
I don't know if this sorting is possible at all..