Added basic openapi support

ref #5
This commit is contained in:
2020-11-25 19:28:52 +01:00
parent 8cbcfe7fbb
commit 3ce9a0b21a
4 changed files with 19 additions and 12 deletions

11
src/loaders/openapi.ts Normal file
View File

@@ -0,0 +1,11 @@
import { Application } from "express";
import * as swaggerUiExpress from "swagger-ui-express";
import { getMetadataArgsStorage } from "routing-controllers";
import { routingControllersToSpec } from "routing-controllers-openapi";
export default async (app: Application) => {
const storage = getMetadataArgsStorage();
const spec = routingControllersToSpec(storage);
app.use("/docs", swaggerUiExpress.serve, swaggerUiExpress.setup(spec));
return app;
};