-
-
Couldn't load subscription status.
- Fork 551
Description
Hi all,
We are using content negotiation (based on accept-header) for versioning the REST resources in our SpringBoot applications.
How can this be properly displayed in Swagger-UI?
We'd like to have
- either 2 separate operations be listed in the Swagger-UI (one per version)
- or 2 groups containing one version each (grouping done by either an own annotation or by evaluating the
io.swagger.v3.oas.annotations)
(?) Can we e.g. use GroupedOpenApi (for example in combination with OperationCustomizer) to define 2 groups (let's say "Current" and "Deprecated") to seperate the versions?
I could not figure out how to create these groups.
The annotation io.swagger.v3.oas.annotations.Operation supports the "hidden" attribute. But this is not reflected in io.swagger.v3.oas.models.Operation. Hence the "operation" can not be modified to be hidden if it does not match the corresponding group.
(?) Can the Operation be "filtered out" in a, OperationCustomizer ?
Or how could we solve this issue?
NOTE:
This came up when migrating to Spring Boot 2.3 and updating to springdoc-openapi-ui.
Previsouly we used an approach with api selectors in the Docket in one of our apps:
@Configuration
@EnableSwagger2
public class SwaggerConfig {
...
...
@Bean
public Docket swaggerSpringMvcPluginDeprecated(
@Value("${info.app.name}") String name,
@Value("${info.app.description}") String description,
@Value("${info.app.version}") String version,
@Value("${info.app.team}") String team,
@Value("${info.app.url}") String url,
@Value("${info.app.contact}") String contact
) {
return new Docket(DocumentationType.SWAGGER_2)
.useDefaultResponseMessages(false)
.select()
.apis(selector -> Objects.requireNonNull(selector).isAnnotatedWith(DeprecatedAPI.class))
.build()
.apiInfo(new ApiInfo(name, description, version, null, new Contact(team, url, contact), null, null, Collections.emptyList()))
.groupName("Deprecated");
}
I highly appreciate any help :-).
Kind regards,
Valentin