Closed
Description
Is your feature request related to a problem? Please describe.
- I would like to create an aggregate Swagger API in the
spring-cloud-gateway
service usingGroupedOpenAPI
. To achieve this, I'm trying to trigger the definitions fromRouteDefinitionLocator
using below sample code
@Bean
List<GroupedOpenApi> groupedOpenApiList(RouteDefinitionLocator locator) {
return locator.getRouteDefinitions()
.filter(
routeDefinition ->
routeDefinition.getId().matches(".*-service"))
.map(
routeDefinition -> {
String name =
routeDefinition
.getId()
.replaceAll("-service", "");
return GroupedOpenApi.builder()
.pathsToMatch("/" + name + "/**")
.group(name)
.build();
})
.toStream()
.toList();
}
I expect MultipleOpenApiSupportConfiguration
to trigger during the AutoConfiguration Scanning as spring boot application contains the Bean of type List<GroupedOpenApi>
, however this is not triggered because of the failed condition @Conditional(MultipleOpenApiSupportCondition.class)
. This is failing as MultipleOpenApiGroupsCondition.class
only accepts a single GroupedOpenApi
Bean or conditional property
Describe the solution you'd like
- Solution to make
MultipleOpenApiGroupsCondition.java
acceptList<GroupedOpenApi>
to make the conditional annotation become true
Describe alternatives you've considered
- Declaring the SpringBoot Main class with below package scanning is making is pass but this is wrong approach
@SpringBootApplication(scanBasePackages = {"org.springdoc.webflux.api", "com.example.api.gateway"})
Additional context
- Below is the sample code used to demonstrate the idea
demo.zip