18

I am using SpringDoc 1.4.3 for swagger.
I have added the below configuration to disabled the petstore URLs in application.yml

Configuration

springdoc:
  swagger-ui:
    disable-swagger-default-url: true
    tags-sorter: alpha
    operations-sorter: alpha
    doc-expansion: none

but when I hit the https://petstore.swagger.io/v2/swagger.json in explore text box, it is still showing me the petsore URLs as shown in the below image.

Swagger Image

Swagger Image

SSK
  • 3,444
  • 6
  • 32
  • 59

5 Answers5

28

Already tested and validated thanks to the following feature support:

Just use, the following property:

springdoc.swagger-ui.disable-swagger-default-url=true
  • yet that is working, but if we add the URL `https://petstore.swagger.io/v2/swagger.json ` explicitly in explore textbox then it is still showing. as shown in the attached screen shot – SSK Aug 03 '20 at 06:15
  • 1
    You should block it in your firewall rules, if you want to block Access. Petstore URL is like any other urls. –  Aug 24 '20 at 12:21
  • add that property for your default API docs URL: springdoc.swagger-ui.url=/v1/api-docs – Dmitri Algazin Oct 10 '22 at 11:12
6

For those if the suggested property setting did not work, clear the browser cache and reload the URL. The property setting DOES WORK. Wasted 2 hours to figure it out.

springdoc:
  swagger-ui:
    disable-swagger-default-url: true
mAsK
  • 189
  • 3
  • 9
1

In my case, I had an incorrectly-defined servlet filter - I was missing a 'return;' statement. This caused the filter chain to not be processed properly, and some of the Swagger requests got borked.

Check to see if you have the following condition:

@Component
public class MyFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {

        if (some condition) {
            chain.doFilter(request, response);

            return;    /**** Don't forget this line! ****/
        }

        ... more logic ...

        chain.doFilter(request, response);
    }
}
Greg
  • 2,476
  • 4
  • 22
  • 28
-1

The only way I got around this was by adding a SwaggerConfig page [tutorial here] and changing to OAS_3 and saving, and then you can either change it to something else after.

return new Docket(DocumentationType.OAS_30)

It just seems like Swagger is keeping a cache or something, but saving a configured OAS_3 seems to let Swagger know to stop using the default.

-5

Set below property, this will disable Swagger OpenApi 3 UI module

springdoc.api-docs.enabled=false
chiragh-rey
  • 103
  • 1
  • 3