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.

3

Best Answer


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.

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.

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

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