question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Support to block Swagger-ui via Spring Profiles

See original GitHub issue

Based 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:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
dilipkrishcommented, May 18, 2017

Isn’t that the most critical part of Spring Boot’s autoconfiguration, which provides all of the base Servlet handling for Spring’s @RestController support, which I’m of course using (and what SpringFox is documenting)?

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

3reactions
vrudikovcommented, Jun 22, 2017

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found