I have a REST API and springfox swagger v2.6.1 included and working. But now, I would like to not always display all the controllers I have, because some of them are very te
You can also Provide package name
@Bean
public Docket api() {
return new Docket( DocumentationType.SWAGGER_2 )
.select()
.apis(RequestHandlerSelectors.basePackage("com.hello.world.controller.user"))
.paths( PathSelectors.any() )
.build()
.apiInfo( metadata() );
}
or you can use custom Annotation for your API classes or API methods as below:
@Bean
public Docket api() {
return new Docket( DocumentationType.SWAGGER_2 )
.select()
.apis(RequestHandlerSelectors.withClassAnnotation(MyCustomClassAnnotation.class))
.paths( PathSelectors.any() )
.build()
.apiInfo( metadata() );
}
@Bean
public Docket api() {
return new Docket( DocumentationType.SWAGGER_2 )
.select()
.apis(RequestHandlerSelectors.withMethodAnnotation(MyCustomMethodAnnotation.class))
.paths( PathSelectors.any() )
.build()
.apiInfo( metadata() );
}