I'm upgrading to SpringFox Swagger 3.0.0 from 2.x, which introduces the Spring Boot starter springfox-boot-starter
dependency that obviates the need for the 2.x-based SwaggerConfig
:
/**
* NO LONGER NEEDED
*/
@Configuration
@EnableSwagger2
@Profile({"local", "dev", "beta"}) // <- HOW TO DISABLE IN PROD INSTEAD OF THIS
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
Now that I no longer need this @Configuration
, which allows me to specify my environment profiles in @Profile
and therefore disable Swagger in production, how do I disable Swagger in production in SpringFox Swagger-UI 3.x?
NOTE: There is Spring Security-based approached discussed here that could be an option for some, but is not an option for this scenario for two reasons:
- My application does not use Spring Security and it is not possible to include the
spring-boot-security-starter
dependency - It requires whitelisting all other endpoints in order to get them working again, which is not acceptable