petstore URL not disabled in SpringDoc OpenAPi

29k views Asked by At

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

5

There are 5 answers

3
AudioBubble On BEST ANSWER

Already tested and validated thanks to the following feature support:

Just use, the following property:

springdoc.swagger-ui.disable-swagger-default-url=true
1
Greg On

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);
    }
}
0
mAsK On

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
1
turniprincess On

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.

1
chiragh-rey On

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

springdoc.api-docs.enabled=false