Skip to content

Instantly share code, notes, and snippets.

@andreigec
Last active April 11, 2019 01:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreigec/88907aaae7878e0bd2fc3c3359224cb0 to your computer and use it in GitHub Desktop.
Save andreigec/88907aaae7878e0bd2fc3c3359224cb0 to your computer and use it in GitHub Desktop.
Standalone swagger html, just provide your swagger api endpoint!
<!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