-
-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for MultipleOpenApiSupport when a Bean of type List<GroupedOpenApi> is present #1919
Comments
…edOpenApi> is present. Fixes #1919
Thanks @bnasslahsen, when is this available for testing? Should I be waiting till 2.0.0-RC2? |
I believe you have few workarounds. |
hello @bnasslahsen, I arrive a bit late but would it be possible that you elaborate on |
Hi @celcius112 , Use below code for grouping as an alternative @Bean
public List<GroupedOpenApi> groupedOpenApis(
RouteDefinitionLocator locator, SwaggerUiConfigProperties swaggerUiConfigProperties) {
Set<AbstractSwaggerUiConfigProperties.SwaggerUrl> swaggerUrls =
swaggerUiConfigProperties.getUrls();
return locator.getRouteDefinitions()
.toStream()
.map(RouteDefinition::getId)
.filter(id -> id.endsWith("-service"))
.map(
routeDefinitionId -> {
String name = extractNameFromRouteDefinitionId(routeDefinitionId);
swaggerUrls.add(
new AbstractSwaggerUiConfigProperties.SwaggerUrl(
name,
"/" + routeDefinitionId + "/v3/api-docs",
routeDefinitionId));
return GroupedOpenApi.builder()
.pathsToMatch("/" + name + "/**")
.group(name)
.build();
})
.toList();
}
private String extractNameFromRouteDefinitionId(String routeDefinitionId) {
return routeDefinitionId.replace("-service", "");
} Sample can be found here |
Is your feature request related to a problem? Please describe.
spring-cloud-gateway
service usingGroupedOpenAPI
. To achieve this, I'm trying to trigger the definitions fromRouteDefinitionLocator
using below sample codeI expect
MultipleOpenApiSupportConfiguration
to trigger during the AutoConfiguration Scanning as spring boot application contains the Bean of typeList<GroupedOpenApi>
, however this is not triggered because of the failed condition@Conditional(MultipleOpenApiSupportCondition.class)
. This is failing asMultipleOpenApiGroupsCondition.class
only accepts a singleGroupedOpenApi
Bean or conditional propertyDescribe the solution you'd like
MultipleOpenApiGroupsCondition.java
acceptList<GroupedOpenApi>
to make the conditional annotation become trueDescribe alternatives you've considered
@SpringBootApplication(scanBasePackages = {"org.springdoc.webflux.api", "com.example.api.gateway"})
Additional context
demo.zip
The text was updated successfully, but these errors were encountered: