The best way I've found to limit the endpoints displayed by the swagger documentation is as follows:
@Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.any()) .paths(paths()) .build().apiInfo(metadata()); } private Predicate<String> paths() { return or( regex("/firstContext.*"), regex("/secondContext.*")); } private ApiInfo metadata() { return new ApiInfoBuilder() .title("SomeTitle") .description("SomeDescription") .build(); }
Thus, each endpoint that does not start with the contexts of the paths () method will not be displayed using swagger
source share