Sorting/Ordering on method (POST, GET, UPDATE, DELETE)
See original GitHub issueDescribe the bug I want to sort the endpoints/Method by methods. While having groups and tags.
Steps to reproduce I used Endpoints with tags. I have grouped API endpoints like these:
@Bean
public GroupedOpenApi internalApi() {
return GroupedOpenApi.builder()
.setGroup("internal")
.packagesToScan(CatalogController.class.getPackageName())
.build();
}
And I used the OpenApiCustomiser like this:
@Bean
public OpenApiCustomiser sort() {
//WE DON'T UNDERSTAND WHERE 'openApi' IS COMMNG FROM - not debugable....
return openApi -> openApi.setPaths(
(Paths) openApi.getPaths().entrySet()
.stream()
.sorted(Comparator.comparingInt(pathItem -> {
if (pathItem.getValue().getGet() != null) {
return 1;
}
return 0;
}))
.collect(toMap(Map.Entry::getKey, Map.Entry::getValue, (x, y) -> y, LinkedHashMap::new))
);
}
Expected behavior Sorting should be debugable and working.
Additional context Would be nice to add these sorting like by Tag/Method,… to the already existing properties next to alphabetic sorting. Also would be great to solve ordering with an annotation…
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Using HTTP Methods for RESTful Services - REST API Tutorial
Click on a tab for more information about the desired HTTP method. POST; GET; PUT; PATCH; DELETE. The POST verb is most-often utilized...
Read more >Does order matter in REST api express, ie. get -> post -> put
No. Order matters only when two routes would handle both the same path and the same method. So, since app.post() and app.
Read more >REST API Design: Filtering, Sorting, and Pagination - Moesif
Advanced REST API design guidelines for API filtering, sorting, and pagination.
Read more >Most Common HTTP Request Methods — POST, GET, PUT ...
POST, GET, PUT, PATCH, and DELETE are the most-commonly-used HTTP verbs. ... In sort, the POST method is used to insert new items...
Read more >HTTP methods - Omnisend API
GET – request used to retrieve data. Never used to delete, update or insert data. · POST – request used to insert data....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@YunaBraska,
Have you looked at the documentation?
You can use the swagger-ui properties, without having to override the standard way of sorting (operationsSorter and tagsSorter).
For example:
Additionnaly, your sample code is not complete, as your GroupedOpenApi doesn’t not reference your OpenApiCustomiser. You should use OpenApiCustomiser, only if you really have some custom ways that are not handled in the standard swagger-ui properties.
You should have something like on your GroupedOpenApi:
I’m running into the same problem (v1.4.3). This is making documenting the differences after a change very hard.
I made no changes to the configuration. Just to the code and this was always in the application.properties file springdoc.swagger-ui.operationsSorter=method
The order of the endpoints used to be GET, PATCH, POST. For some reason now, it’s POST, GET, PATCH.
In addition to the endpoints itself, even some (though not all) attribute order has changed. Not sure what I need to do to fix that. springdoc.swagger-ui.tagsSorter=alpha?
I don’t know if this worked by fluke previously. Since I only changed the model classes, I don’t see how what could have triggered this change.