Home » Java » java – Spring mvc Swagger UI endpoint for two different URL pattern-Exceptionshub

java – Spring mvc Swagger UI endpoint for two different URL pattern-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I have two different url patterns one which starts with /api and second which starts with /svc. So, my question here is can we have two different swagger endpoint urls for these both API documentation using Swagger ?

I am using Spring MVC and Swagger for documentation purpose. Any hint please ? Thanks in advance!

How to&Answers:
@Configuration
@EnableSwagger2
public class SwaggerConfig {

 @Bean
    public Docket api() { 
        return new Docket(DocumentationType.SWAGGER_2)  
          .select()                                  
          .apis(RequestHandlerSelectors.any())              
          .paths(PathSelectors.any())                          
          .build();                                           
    }
}

This has to help you.
The code:

apis(RequestHandlerSelectors.any())  

will select all the apis from your controllers.