Compare commits

...

2 Commits

4 changed files with 30 additions and 5 deletions

2
.gitignore vendored
View File

@ -132,5 +132,5 @@ build
*.sqlite *.sqlite
*.sqlite-jurnal *.sqlite-jurnal
docs /docs
lib lib

View File

@ -1,5 +1,6 @@
import { validationMetadatasToSchemas } from "class-validator-jsonschema"; import { validationMetadatasToSchemas } from "class-validator-jsonschema";
import { Application } from "express"; import express, { Application } from "express";
import path from 'path';
import { getMetadataArgsStorage } from "routing-controllers"; import { getMetadataArgsStorage } from "routing-controllers";
import { routingControllersToSpec } from "routing-controllers-openapi"; import { routingControllersToSpec } from "routing-controllers-openapi";
import * as swaggerUiExpress from "swagger-ui-express"; import * as swaggerUiExpress from "swagger-ui-express";
@ -51,12 +52,13 @@ export default async (app: Application) => {
explorer: true, explorer: true,
}; };
app.use( app.use(
"/api/docs", "/api/docs/swagger",
swaggerUiExpress.serve, swaggerUiExpress.serve,
swaggerUiExpress.setup(spec, options) swaggerUiExpress.setup(spec, options)
); );
app.get(["/api/openapi.json", "/api/swagger.json"], (req, res) => { app.get(["/api/docs/openapi.json", "/api/docs/swagger.json"], (req, res) => {
res.json(spec); res.json(spec);
}); });
app.use('/api/docs', express.static(path.join(__dirname, '../static/docs'), { index: "index.html", extensions: ['html'] }));
return app; return app;
}; };

View File

@ -36,7 +36,14 @@ const spec = routingControllersToSpec(
"AuthToken": { "AuthToken": {
"type": "http", "type": "http",
"scheme": "bearer", "scheme": "bearer",
"bearerFormat": "JWT" "bearerFormat": "JWT",
description: "A JWT based access token. Use /api/auth/login or /api/auth/refresh to get one."
},
"RefreshTokenCookie": {
"type": "apiKey",
"in": "cookie",
"name": "lfk_backend__refresh_token",
description: "A cookie containing a JWT based refreh token. Attention: Doesn't work in swagger-ui. Use /api/auth/login or /api/auth/refresh to get one."
} }
} }
}, },

View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<h1>Pick your poison</h1>
<ul>
<li>
<a href="./redoc">ReDoc</a>
</li>
<li>
<a href="./swagger">SwaggerUI</a>
</li>
<li>
<a href="./rapidoc">RapiDoc</a>
</li>
<li>
<a href="./openapi.json">Raw Spec (json)</a>
</li>
</ul>