fixed component definition

ref #5
This commit is contained in:
Nicolai Ort 2020-11-26 13:45:22 +01:00
parent 796b8942d8
commit 51ff9defc5

View File

@ -2,23 +2,27 @@ import { Application } from "express";
import * as swaggerUiExpress from "swagger-ui-express"; import * as swaggerUiExpress from "swagger-ui-express";
import { getMetadataArgsStorage } from "routing-controllers"; import { getMetadataArgsStorage } from "routing-controllers";
import { routingControllersToSpec } from "routing-controllers-openapi"; import { routingControllersToSpec } from "routing-controllers-openapi";
import { validationMetadatasToSchemas } from 'class-validator-jsonschema'; import { validationMetadatasToSchemas } from "class-validator-jsonschema";
export default async (app: Application) => { export default async (app: Application) => {
const storage = getMetadataArgsStorage(); const storage = getMetadataArgsStorage();
const schemas = validationMetadatasToSchemas({ const schemas = validationMetadatasToSchemas({
refPointerPrefix: '#/components/schemas/', refPointerPrefix: "#/components/schemas/",
}); });
const spec = routingControllersToSpec(storage, {}, { const spec = routingControllersToSpec(
components: { storage,
schemas, {},
info: { {
description: 'LfK! Backend API`', components: {
title: 'LfK! Backend API', schemas,
version: '1.0.0' },
} info: {
}); description: "LfK! Backend API`",
app.use("/docs", swaggerUiExpress.serve, swaggerUiExpress.setup(spec)); title: "LfK! Backend API",
return app; version: "1.0.0",
},
}
);
app.use("/docs", swaggerUiExpress.serve, swaggerUiExpress.setup(spec));
return app;
}; };