Added very basic api doc chooser

ref #52
This commit is contained in:
2020-12-23 15:11:04 +01:00
parent d8e38f404d
commit ebedea97ed
8 changed files with 383 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
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 { routingControllersToSpec } from "routing-controllers-openapi";
import * as swaggerUiExpress from "swagger-ui-express";
@@ -51,12 +52,13 @@ export default async (app: Application) => {
explorer: true,
};
app.use(
"/api/docs",
"/api/docs/swagger",
swaggerUiExpress.serve,
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);
});
app.use('/api/docs', express.static(path.join(__dirname, '../static/docs'), { index: "index.html", extensions: ['html'] }));
return app;
};