Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Last active February 8, 2021 09:59
Show Gist options
  • Save miguelmota/289643541cf55825f14d2ea66598bf64 to your computer and use it in GitHub Desktop.
Save miguelmota/289643541cf55825f14d2ea66598bf64 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