在Swagger2中隐藏/删除Spring MVC端点

Yog*_*Rai 4 spring-mvc swagger swagger-ui spring-boot swagger-2.0

我正在使用Swagger 2进行API UI.所以,我gradle.build有:

compile "io.springfox:springfox-swagger2:${swaggerVersion}"
compile "io.springfox:springfox-swagger-ui:${swaggerVersion}"
Run Code Online (Sandbox Code Playgroud)

我已将Swagger配置如下:

@Configuration
@Profile("!production")
@EnableSwagger2
@ComponentScan(basePackageClasses = com.company.controllers.ContentController.class)
public class SwaggerConfiguration {
    @Autowired
    private BuildInfo buildInfo;

    @Bean
    public Docket awesomeApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(this.awesomeApiInfo())
                .select()
                .apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.boot")))
                .build();

    }

    private ApiInfo awesomeApiInfo() {
        return new ApiInfoBuilder()
                .title("Awesome API - build #" + this.buildInfo.getVersion())
                .description("Enter the IDs in order to look for the content")
                .version("0.1")
                .build();
    }
}
Run Code Online (Sandbox Code Playgroud)

我正在获取我已经定义的api端点,但也获得了如下的Spring MVC端点:

在此输入图像描述

现在,我需要摆脱这些mvc端点.

任何帮助都非常感谢!!

Yog*_*Rai 10

哦......实际上这是我的愚蠢错误.我更改了RequestHandlerSelectors以从我自己的控制器包中仅选择端点,如下所示:

 @Bean
    public Docket awesomeApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(this.awesomeApiInfo())
                .select()
                .paths(PathSelectors.any())
                .apis(RequestHandlerSelectors.basePackage("com.company.awesome.controllers"))
                .build();

    }
Run Code Online (Sandbox Code Playgroud)

这只显示了controller包中类中映射的端点.