Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const routingControllersOptions = {
controllers: [UsersController],
routePrefix: '/api'
}
const app: Express = createExpressServer(routingControllersOptions)
// Parse class-validator classes into JSON Schema:
const metadatas = (getFromContainer(MetadataStorage) as any).validationMetadatas
const schemas = validationMetadatasToSchemas(metadatas, {
refPointerPrefix: '#/components/schemas/'
})
// Parse routing-controllers classes into OpenAPI spec:
const storage = getMetadataArgsStorage()
const spec = routingControllersToSpec(storage, routingControllersOptions, {
components: {
schemas,
securitySchemes: {
basicAuth: {
scheme: 'basic',
type: 'http'
}
}
},
info: {
description: 'Generated with `routing-controllers-openapi`',
title: 'A sample API',
version: '1.0.0'
}
})