Filtering an API from Swagger's documentation

Let's see the following updated Docket bean configuration:

@Bean 
public Docket api() {  
   return new Docket(DocumentationType.SWAGGER_2)           
           .select()                                        
           .apis(RequestHandlerSelectors.basePackage("com.dineshonjava.accountservice.controller"))           .paths(PathSelectors.ant("/customer/*"))                      
           .build(); 
} 
 

In the preceding configuration of the Docket bean, we have filtered some APIs from the documentation. Sometimes, we don't want to expose the documentation of some APIs. You can pass parameters to the apis() and paths() methods of the Docket class to restrict Swagger's response. The RequestHandlerSelectors class allows you to use the any or none predicates. You can use RequestHandlerSelectors to filter the API according ...

Get Mastering Spring Boot 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.