Last active
April 11, 2019 01:05
-
-
Save andreigec/88907aaae7878e0bd2fc3c3359224cb0 to your computer and use it in GitHub Desktop.
Standalone swagger html, just provide your swagger api endpoint!
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Swagger UI</title> | |
<link | |
rel="stylesheet" | |
type="text/css" | |
href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.22.0/swagger-ui.css" | |
/> | |
<script> | |
if (window.navigator.userAgent.indexOf("Edge") > -1) { | |
console.log( | |
"Removing native Edge fetch in favor of swagger-ui's polyfill" | |
); | |
window.fetch = undefined; | |
} | |
</script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.22.0/swagger-ui-bundle.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.22.0/swagger-ui-standalone-preset.js"></script> | |
</head> | |
<body> | |
<div id="swagger-ui"></div> | |
</body> | |
<footer> | |
<script> | |
window.onload = function() { | |
/** PUT YOUR API DETAILS HERE*/ | |
var api = XXXX; | |
var apiName = YYYY; | |
/** END CUSTOM*/ | |
var configObject = { | |
urls: [{ url: api, name: apiName }], | |
validatorUrl: "https://validator.swagger.io/validator" | |
}; | |
configObject.dom_id = "#swagger-ui"; | |
configObject.presets = [ | |
SwaggerUIBundle.presets.apis, | |
SwaggerUIStandalonePreset | |
]; | |
configObject.plugins = [SwaggerUIBundle.plugins.DownloadUrl]; | |
configObject.layout = "StandaloneLayout"; | |
const ui = SwaggerUIBundle(configObject); | |
}; | |
</script> | |
</footer> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment