Support multiple apis() in swagger config
See original GitHub issueHere I tried to add the Spring-Actuator endpoints according to the stackoverflow issue - http://stackoverflow.com/questions/39159998/swagger2-document-a-springboot-mvcendpoint,
So I created the following swagger config, but seems the sendond apis will override the first one.
@Configuration
@EnableSwagger2
public class Swagger2Config {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.apis(RequestHandlerSelectorsExt.withInterface())
.paths(PathSelectors.any()).build();
}
static class RequestHandlerSelectorsExt {
public static Predicate<RequestHandler> withInterface() {
return new Predicate<RequestHandler>() {
@Override
public boolean apply(RequestHandler input) {
return declaringClass(input) == EndpointMvcAdapter.class;
}
};
}
private static Class<?> declaringClass(RequestHandler input) {
return input.getHandlerMethod().getMethod().getDeclaringClass();
}
}
}
Fome the source codes, seems this is a bug?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Documentation Portals for Multiple APIs | Swagger Blog
Lets put the swaggerhub function to use and create a new getOrganizationData call. This will take a single input parameter, our organization's ...
Read more >Combining multiple Swagger API endpoints in a single UI
By switching from one service to another from a list, you will get the Swagger UI rendered out based on the Open API...
Read more >Support multiple pathmapping in Swagger UI/Spring boot
I am having swagger configuration like blow. @Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket postsApi() { return ...
Read more >Distributed API Documentation - How to Aggregate Swagger
Configuring the Swagger UI to serve multiple API documents. The list of configured services is used to generate a response to /swagger-config.
Read more >How to implement Swagger UI for multiple API's : r/golang
The second part of this is the swagger ui setup that renders all the various sub service swagger files into something that can...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It can have only one api call (last one wins) but can have multiple predicates. For e.g.
.apis(Predicates.or(firstApi(), secondApi()
I solved a similar problem by defining my own controller annotation and attach it to the classes I want include …
to find my documentation classes I used the following code …