Skip to content

Instantly share code, notes, and snippets.

@rochacbruno
Forked from miguelmota/swagger-ui-config.js
Created May 18, 2018 23:03
Show Gist options
  • Save rochacbruno/e05f69e7a37e4dcd417425c1567f3c53 to your computer and use it in GitHub Desktop.
Save rochacbruno/e05f69e7a37e4dcd417425c1567f3c53 to your computer and use it in GitHub Desktop.
Swagger UI set scheme to window location protocol
window.onload = function() {
fetch('./swagger.json')
.then(function(response) {
response.json()
.then(function(json) {
json.schemes[0] = window.location.protocol.slice(0, -1)
json.host = window.location.host
const ui = SwaggerUIBundle({
spec: json,
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
]
})
window.ui = ui
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment