Closed
Description
Hi,
Problem: unsorted groups
when defining multiple groups as:
@Bean
public GroupedOpenApi openApiServices() {
return GroupedOpenApi.builder()
.setGroup("Group Name A")
.pathsToMatch("/some/path/pattern/**")
.build();
}
it seems to result in an arbitrary ordered list of groups in swagger config, as in example:
"urls": [
{
"url": "/sasmd/v3/api-docs/9-Actuator",
"name": "9-Actuator"
},
{
"url": "/sasmd/v3/api-docs/2-Security",
"name": "2-Security"
},
{
"url": "/sasmd/v3/api-docs/1-Other",
"name": "1-Other"
}
]
I would like as the default behavior to sort the groups by name.
Solution
A possible solution would be to change org/springdoc/core/SwaggerUiConfigProperties.java:376
(see: 26d58f2):
swaggerUrls = swaggerUrls.stream().filter(elt -> StringUtils.isNotEmpty(elt.getUrl())).sorted().sorted(Comparator.comparing(SwaggerUrl::getName)).collect(Collectors.toList());
Alternatives
maybe also a "order" attribute on the GroupedOpenApi.builder()
would be nice to have.
Best,
-Stefan
P.S.: if you like the idea and would prefer a pull request, let me know. Thanks.