Now creating (json)schemas from class validator annotated classes
ref #5
This commit is contained in:
parent
a6bd723511
commit
796b8942d8
|
@ -25,6 +25,7 @@
|
|||
"body-parser": "^1.19.0",
|
||||
"class-transformer": "^0.3.1",
|
||||
"class-validator": "^0.12.2",
|
||||
"class-validator-jsonschema": "^2.0.3",
|
||||
"consola": "^2.15.0",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
|
|
|
@ -2,10 +2,23 @@ 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';
|
||||
|
||||
|
||||
export default async (app: Application) => {
|
||||
const storage = getMetadataArgsStorage();
|
||||
const spec = routingControllersToSpec(storage);
|
||||
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;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue