fixed component definition

ref #5
This commit is contained in:
Nicolai Ort 2020-11-26 13:45:22 +01:00
parent 796b8942d8
commit 51ff9defc5
1 changed files with 21 additions and 17 deletions

View File

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