Avoid showing Spring Framework specific services as part of Swagger interface

六眼飞鱼酱① 提交于 2020-01-03 02:22:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!