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?
You can disable using below property
springfox.documentation.enabled=false
Springfox Boot Starter API enable by default the 'auto-startup' configuration, means Swagger UI html page (ex. /swagger-ui/index.html) and Api-Docs (/v2/api-docs) JSON page containing a swagger with All API definitions.
For production environment is a good choise disable all the API documentation.
To disable all the swagger auto-configurations you can add on your application-prod.properties file the property below:
springfox.documentation.auto-startup=false
In this case with Your config on prod you have nothing about swagger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With