Added basic apispec generator
This commit is contained in:
parent
53daae956d
commit
124c7a5d15
33
src/apispec.ts
Normal file
33
src/apispec.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import { MetadataArgsStorage } from 'routing-controllers';
|
||||||
|
import { routingControllersToSpec } from 'routing-controllers-openapi';
|
||||||
|
import { config } from './config';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function generates a the openapi spec from route metadata and type schemas.
|
||||||
|
* @param storage MetadataArgsStorage object generated by routing-controllers.
|
||||||
|
* @param schemas MetadataArgsStorage object generated by class-validator-jsonschema.
|
||||||
|
*/
|
||||||
|
export function generateSpec(storage: MetadataArgsStorage, schemas) {
|
||||||
|
return routingControllersToSpec(
|
||||||
|
storage,
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
components: {
|
||||||
|
schemas,
|
||||||
|
"securitySchemes": {
|
||||||
|
"AuthToken": {
|
||||||
|
"type": "apiKey",
|
||||||
|
"in": "query",
|
||||||
|
"name": "key",
|
||||||
|
description: "A simple api key. See the README's env section for more details."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
info: {
|
||||||
|
description: "The the API for the LfK! mailer.",
|
||||||
|
title: "LfK! mailer API",
|
||||||
|
version: config.version
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user