Skip to content

Instantly share code, notes, and snippets.

@o-az
Last active March 25, 2024 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save o-az/36b94d57a8df23421f229a15b5ae7a10 to your computer and use it in GitHub Desktop.
Save o-az/36b94d57a8df23421f229a15b5ae7a10 to your computer and use it in GitHub Desktop.
barebone index.html to use for swagger ui. Assumes you have a swagger.json file ready
<!doctype html>
<html lang='en'>
<head>
<meta charset='UTF-8' />
<title>_TITLE_</title>
<link rel='stylesheet' type='text/css' href='https://unpkg.com/swagger-ui-dist/swagger-ui.css' />
<style>
*,
*:before,
*:after {
box-sizing: inherit;
}
*::-webkit-scrollbar {
height: 0.3rem;
width: 0rem;
}
*::-webkit-scrollbar-track {
-ms-overflow-style: none;
overflow: -moz-scrollbars-none;
}
*::-webkit-scrollbar-thumb {
-ms-overflow-style: none;
overflow: -moz-scrollbars-none;
}
@supports (scrollbar-gutter: stable) {
html {
overflow-y: auto;
scrollbar-gutter: stable;
}
}
html {
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
margin: 0;
background: #FFFFFF;
}
.errors-wrapper {
display: none !important;
}
</style>
</head>
<body>
<main id='swagger-ui'>
<script src='https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js' charset='UTF-8'></script>
<script src='https://unpkg.com/swagger-ui-dist/swagger-ui-standalone-preset.js' charset='UTF-8'></script>
<script>
window.onload = () => window.ui =
SwaggerUIBundle({
/**
* URL to fetch spec from
* Alternatively, remove url and set `spec` to an object containing openapi spec itself
*/
url: '__OPENAPI_URL__',
deepLinking: true,
dom_id: '#swagger-ui',
layout: 'StandaloneLayout',
plugins: [SwaggerUIBundle.plugins.DownloadUrl],
presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment