问题
I am using spring-boot-starter-parent 1.3.3.RELEASE. I am unable to disable the following endpoints in Swagger UI.
Need To Disable:-
Entity Metadata Services
profile-controller
repository-controller
I disabled the following endpoints using the code..
Disabled endpoints:-
environment-manager-mvc-endpoint
generic-postable-mvc-endpoint
restart-mvc-endpoint
Code:-
public Docket appHierarchyServiceApi() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.boot")))
.paths(PathSelectors.any()).build()
How to disable the profile and repository controller in Swagger UI??
Kindly provide your inputs.
回答1:
use a regex within .paths(...)
I use the following :
.paths(PathSelectors.regex(""^/(?!error|autoconfig|beans|configprops|dump|info|mappings|trace|env|metrics).*$""))
回答2:
I use these:
.apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.boot")))
.apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.cloud")))
.apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.data.rest.webmvc")))
来源:https://stackoverflow.com/questions/40238166/avoid-showing-spring-framework-specific-services-as-part-of-swagger-interface