Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide repository-controller from Swagger UI

I am using spring-boot-starter-parent 1.3.3.RELEASE. I am unable to disable repository controller in Swagger UI

enter image description here

I have disabled the other unwanted endpoints using this link.

How to disable repository-controller from swagger UI?? kindly provide your inputs

If use the follow, it returns only the search repository which written by me but I need the entity endpoints also. Those entities endpoints will return by spring defaults.

.apis(RequestHandlerSelectors.basePackage("bla.blablah.bla"))

Kindly refer the image: enter image description here

like image 915
SST Avatar asked Dec 20 '25 17:12

SST


1 Answers

When initializing your Docket in your Application class, you can filter package names easily, therefore it will create your api for only given base package:

@Bean
public Docket swaggerSpringMvcPlugin(){
    return new Docket( DocumentationType.SWAGGER_2 )//
            .select().apis( RequestHandlerSelectors.basePackage( "com.blabla.bla" ) )//
            .build();
}

Another solution:

return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select() 
          .apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.boot")))
             .build();

Another solution that negates a specific package:

return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select() 
          .apis(RequestHandlerSelectors.basePackage("org.springframework.boot").negate())
             .build();
like image 71
Sercan Ozdemir Avatar answered Dec 23 '25 07:12

Sercan Ozdemir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!