Last active
February 8, 2021 09:59
-
-
Save miguelmota/289643541cf55825f14d2ea66598bf64 to your computer and use it in GitHub Desktop.
Swagger UI set scheme to window location protocol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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