Swagger-ui: url parameter is ignored in Swagger 3.x it always defaults to the petstore

Created on 7 May 2017  路  6Comments  路  Source: swagger-api/swagger-ui

swagger-ui version: 3.0.9

I am trying to get swagger-ui to load my api definition file instead of the default petstore one, however modifying the url parameter for SwaggerUIBundle in the index.html file has no effect.

I was able to work around it by doing a find and replace for "https://petstore.swagger.io/v2/swagger.json" in swagger-ui-standalone-preset.js so my guess is that the presets are overriding the explicitly defined url param.

P1 lock-bot bug 3.x

Most helpful comment

Yup, this is a bug, and indeed a big one. We have introduced in 3.0.9 a new mechanism to actually make configs more flexible, but... we ended up breaking the simple way of configuring it.

To get it working for now, check out the instructions at https://github.com/swagger-api/swagger-ui#configs-plugin. What's broken is that the constructor config should take over the pre-compiled configs, otherwise...

All 6 comments

@talawahtech

The example from 3.0.8 worked for me after I changed the url in index.html. Something must have broken 3.0.9 recently.

same issue here

Same - after 3.0.9 update


Also wrong redirect_uri is send do identity server - "redirect_uri": "http://localhost:3200/oauth2-redirect.html" (some default value??), instead the one set in SwaggerUIBundle oauth2RedirectUrl property

+1 Same here

Can work around this for now by modifying the very end of swagger-ui-standalone-preset.js. Not 100% what other implications this might have, if any, but my v3.0.9 default url seems to be loading properly and the UI is functional.

Change:
e.exports='---\nurl: "http://petstore.swagger.io/v2/swagger.json"\ndom_id: "#swagger-ui"\nvalidatorUrl: "https://online.swagger.io/validator"\noauth2RedirectUrl: "http://localhost:3200/oauth2-redirect.html"\n'

To:
e.exports=''

Will probably work for @rstraszewski 's oauth URL issue as well.

Yup, this is a bug, and indeed a big one. We have introduced in 3.0.9 a new mechanism to actually make configs more flexible, but... we ended up breaking the simple way of configuring it.

To get it working for now, check out the instructions at https://github.com/swagger-api/swagger-ui#configs-plugin. What's broken is that the constructor config should take over the pre-compiled configs, otherwise...

Was this page helpful?
0 / 5 - 0 ratings