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(
storage,
{},
{
components: { components: {
schemas, schemas,
},
info: { info: {
description: 'LfK! Backend API`', description: "LfK! Backend API`",
title: 'LfK! Backend API', title: "LfK! Backend API",
version: '1.0.0' version: "1.0.0",
},
} }
}); );
app.use("/docs", swaggerUiExpress.serve, swaggerUiExpress.setup(spec)); app.use("/docs", swaggerUiExpress.serve, swaggerUiExpress.setup(spec));
return app; return app;
}; };