'Swagger-ui keeps showing example petstore instead of provided swagger.json

I followed instructions to set up swagger documentation for my existing node API using swagger-jsdoc. The swagger.json is being served correctly and I added a path to it in the url parameter of the SwaggerUiBundle in index.html like this:

const ui = SwaggerUIBundle({
url: "https://my.domain:5292/swagger.json",
dom_id: '#swagger-ui',
presets: [
  SwaggerUIBundle.presets.apis,
  SwaggerUIStandalonePreset
],
plugins: [
  SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout" })

However, the first thing it tries to do when opening the page in the browser is showing the default http://petstore.swagger.io/v2/swagger.json instead of my swagger.json. It actually fails to do so because I'm serving the page through https and the petstore is not https but that's a different matter...

Inputing my address to the swagger.json manually into the form on the page works as expected. It shows the API page correctly and validates it. However, I don't want to always re-enter the address there and would like to have it as a default.



Solution 1:[1]

Swagger UI 3.0.9 had a bug where it ignored the url parameter and always opened Petstore.

It was fixed in 3.0.10.

Solution 2:[2]

I had been having this issue lately when deploying using docker. Tried everything from changing all instance of petstore to my own api json docs but to no avail. Finally I found out about API_URL environment variable, set it to my api docs in DockerFile and voila! Took me two days but it was great to see it finally working.

Solution 3:[3]

You can disabled default url by adding below configuration in application.property file

springdoc.swagger-ui.disable-swagger-default-url=true

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 maria
Solution 3 Jay Patel