switched over to using the static deployment of swaggerUI

ref #52
This commit is contained in:
Nicolai Ort 2020-12-23 15:20:06 +01:00
parent bd46a48f76
commit 39ad43bbb2
6 changed files with 8969 additions and 11 deletions

View File

@ -3,7 +3,6 @@ import express, { Application } from "express";
import path from 'path';
import { getMetadataArgsStorage } from "routing-controllers";
import { routingControllersToSpec } from "routing-controllers-openapi";
import * as swaggerUiExpress from "swagger-ui-express";
/**
* Loader for everything openapi related - from creating the schema to serving it via a static route and swaggerUiExpress.
@ -47,15 +46,15 @@ export default async (app: Application) => {
}
);
//Options for swaggerUiExpress
const options = {
explorer: true,
};
app.use(
"/api/docs/swagger",
swaggerUiExpress.serve,
swaggerUiExpress.setup(spec, options)
);
// //Options for swaggerUiExpress
// const options = {
// explorer: true,
// };
// app.use(
// "/api/docs/swagger",
// swaggerUiExpress.serve,
// swaggerUiExpress.setup(spec, options)
// );
app.get(["/api/docs/openapi.json", "/api/docs/swagger.json"], (req, res) => {
res.json(spec);
});

View File

@ -5,7 +5,7 @@
<a href="./redoc">ReDoc</a>
</li>
<li>
<a href="./swagger">SwaggerUI</a>
<a href="./swaggerui">SwaggerUI</a>
</li>
<li>
<a href="./rapidoc">RapiDoc</a>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,58 @@
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after
{
box-sizing: inherit;
}
body
{
margin:0;
background: #fafafa;
}
</style>
</head>
<body>
<div id="swagger-ui"></div>
<script src="./swagger-ui-bundle.js" charset="UTF-8"> </script>
<script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
<script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "/api/docs/openapi.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
// End Swagger UI call region
window.ui = ui
}
</script>
</body>
</html>