Skip to content

Instantly share code, notes, and snippets.

@cdjones32
cdjones32 / change_swagger_host.js
Last active June 7, 2018 22:58 — forked from hareeqi/change_swagger_host.js
dynamic host for swagger ui 3.x
// not the most elgant way but it works
// Modified to poll until the spec has loaded and then update to the current URL.
// Useful for microservices where you deploy the swagger-ui as part of the bundle and
// the Scheme/Hostname/Port are not know at runtime (for example, because they are being hosted by
// Docker, Kubernetes etc...)
function changeSwagger() {
// Try to get the Spec
var newspec = ui.spec().toJSON().resolved;