swagger-api / swagger-api/swagger-ui
Cannot aggregate multiple swagger specifications in the same swagger-ui
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
OS: macOS
Browser: Chrome and firefox
Version: 99.0.4844.84 and 98.0.2
Method of installation: java maven
Swagger-UI version: 3.0.0
Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
@Configuration
@EnableOpenApi
public class FrameDocumentationProvider {
private static final String SWAGGER_VERSION = "3.0";
@Autowired
private OpenApiProperties openApiProperties;
@Primary
@Bean
public SwaggerResourcesProvider swaggerResourcesProvider(InMemorySwaggerResourcesProvider defaultResourcesProvider) {
return () -> {
List<SwaggerResource> resources = new ArrayList<>();
for (Entry<String, OpenAPIPropertiesModule> moduleEntry : openApiProperties.getModules().entrySet()) {
SwaggerResource wsResource = new SwaggerResource();
wsResource.setName(moduleEntry.getKey());
wsResource.setSwaggerVersion(SWAGGER_VERSION);
OpenAPIPropertiesModule moduleProperties = moduleEntry.getValue();
wsResource.setLocation(moduleProperties.getApi());
resources.add(wsResource);
}
return resources;
};
}
private SwaggerResource swaggerResource(String name, String location) {
SwaggerResource swaggerResource = new SwaggerResource();
swaggerResource.setName(name);
swaggerResource.setLocation(location);
swaggerResource.setSwaggerVersion(SWAGGER_VERSION);
return swaggerResource;
}
@Bean
UiConfiguration uiConfig() {
return UiConfigurationBuilder.builder()
.swaggerUiBaseUrl(openApiProperties.getHost())
.deepLinking(true)
.displayOperationId(false)
.defaultModelsExpandDepth(-1)
.defaultModelExpandDepth(1)
.defaultModelRendering(ModelRendering.EXAMPLE)
.displayRequestDuration(false)
.docExpansion(DocExpansion.NONE)
.filter(false)
.maxDisplayedTags(null)
.operationsSorter(OperationsSorter.ALPHA)
.showExtensions(false)
.showCommonExtensions(false)
.tagsSorter(TagsSorter.ALPHA)
.supportedSubmitMethods(UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS)
.validatorUrl(null)
.build();
}
@Bean
public Docket api() {
return new Docket(DocumentationType.OAS_30)
.apiInfo(apiInfo())
.enableUrlTemplating(true)
.securitySchemes(securitySchemes())
.select()
.apis(RequestHandlerSelectors.any())
.paths(Predicate.not(PathSelectors.regex("/error")))
.build();
}
private ApiInfo apiInfo() {
return new ApiInfo();
}
private List<SecurityScheme> securitySchemes() {
return List.of(new ApiKey(
"OAuth Authorization Token",
"Authorization",
"header"));
}
}
Describe the bug you're encountering
When return multiple resources to the swagger-ui the inferface only loads the data from the first resource of the list.
To reproduce...
Steps to reproduce the behavior:
- Create muiltiple resources and create a primary bean that returns them
- load swagger-ui in the browser
- only loads endpoints from the first resource
Expected behavior
Loads endpoints from all resources.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file or test is named in the issue. Reproduce the problem in Swagger UI with the Java configuration returning multiple Swagger resources, then trace how the resource list is loaded; done means endpoints from every resource appear in the interface rather than only the first.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, javascript, openapi
- Domain
- documentation, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100