51
src/apispec.ts
Normal file
51
src/apispec.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
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,
|
||||
{
|
||||
routePrefix: "/api"
|
||||
},
|
||||
{
|
||||
components: {
|
||||
schemas,
|
||||
"securitySchemes": {
|
||||
"AuthToken": {
|
||||
"type": "http",
|
||||
"scheme": "bearer",
|
||||
"bearerFormat": "JWT",
|
||||
description: "A JWT based access token. Use /api/auth/login or /api/auth/refresh to get one."
|
||||
},
|
||||
"RefreshTokenCookie": {
|
||||
"type": "apiKey",
|
||||
"in": "cookie",
|
||||
"name": "lfk_backend__refresh_token",
|
||||
description: "A cookie containing a JWT based refreh token. Attention: Doesn't work in swagger-ui. Use /api/auth/login or /api/auth/refresh to get one."
|
||||
},
|
||||
"StatsApiToken": {
|
||||
"type": "http",
|
||||
"scheme": "bearer",
|
||||
description: "Api token that can be obtained by creating a new stats client (post to /api/statsclients). Only valid for obtaining stats."
|
||||
},
|
||||
"StationApiToken": {
|
||||
"type": "http",
|
||||
"scheme": "bearer",
|
||||
description: "Api token that can be obtained by creating a new scan station (post to /api/stations). Only valid for creating scans."
|
||||
}
|
||||
}
|
||||
},
|
||||
info: {
|
||||
description: "The the backend API for the LfK! runner system.",
|
||||
title: "LfK! Backend API",
|
||||
version: config.package_version,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user