swagger-uispringfox-boot-starter

SpringFox Boot starter: How to disable swagger-ui for production profile?


I am using the io.springfox springfox-boot-starter v 3.0.0,

According to the documentation, this Spring Boot setup would disable the swagger endpoint for prod:

@Configuration
@Profile({"!prod && swagger"})
public class SwaggerConfig implements WebMvcConfigurer {

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .useDefaultResponseMessages(false)
                .select()
                .apis(RequestHandlerSelectors.any())
                .build()
                .apiInfo(apiInfo());
    }

...

When on prod, the customisations of swagger defined here are indeed missing, but the Swagger UI endpoint is still there. How can I suppress the /swagger-ui/ endpoint altogether? Is there nothing like a springfox.swagger-ui.enabled=false property I can set somewhere in the spring boot application configuration?


Solution

  • You can disable using below property

    springfox.documentation.enabled=false