Add Support to block Swagger-ui via Spring Profiles
See original GitHub issueBased on this SO answer, it appears the recommended way to disable the swagger endpoint hosting is by using an @Profile
annotation on the @Configuration
class for Springfox. This works great for the swagger endpoints themselves. But how do you also disable the /swagger-ui.html
and webjars/
endpoints with that same profile?
For example, if you’re using these dependencies in build.gradle
:
compile 'io.springfox:springfox-swagger2:2.6.1'
compile 'io.springfox:springfox-swagger-ui:2.6.1'
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How to Turn Off Swagger-ui in Production - Baeldung
To disable Swagger in production, let's toggle whether this configuration bean is injected. 3. Using Spring Profiles.
Read more >java - How to fully disable swagger-ui in spring-boot ...
My answer is similar to the answer provided earlier with a slight difference. I usually create a separate spring profile named swagger ....
Read more >Understand Spring Boot + Profiles using simple example
Go to http://localhost:8080/swagger-ui.html. Spring Boot Swagger Tutorial So using Spring Profiles we can enable or disable the loading of any bean. Download ...
Read more >Spring Boot disable Swagger-ui in Production - Geeky Hacker
Spring Boot disable Swagger-ui in Production. To disable Swagger-ui for production profile, first we need to define a maven profile.
Read more >Using OpenAPI and Swagger UI - Quarkus
We can however change this to only serve the static OpenAPI document by adding mp.openapi.scan.disable=true configuration into application.properties .
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A little googling leads me to believe you can easily do this via a setting in your property/yaml file under specific profiles.
spring.resources.add-mappings=false
@pluttrell i’ve used
spring.resources.add-mappings=false
and it helped me a lot, because my server is API only. i don’t have any web-resources there