@@ -2,8 +2,7 @@ import { validationMetadatasToSchemas } from "class-validator-jsonschema";
|
||||
import express, { Application } from "express";
|
||||
import path from 'path';
|
||||
import { getMetadataArgsStorage } from "routing-controllers";
|
||||
import { routingControllersToSpec } from "routing-controllers-openapi";
|
||||
import { config } from '../config';
|
||||
import { generateSpec } from '../apispec';
|
||||
|
||||
/**
|
||||
* Loader for everything openapi related - from creating the schema to serving it via a static route and swaggerUiExpress.
|
||||
@@ -16,46 +15,7 @@ export default async (app: Application) => {
|
||||
});
|
||||
|
||||
//Spec creation based on the previously created schemas
|
||||
const spec = 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,
|
||||
},
|
||||
}
|
||||
);
|
||||
const spec = generateSpec(storage, schemas);
|
||||
app.get(["/api/docs/openapi.json", "/api/docs/swagger.json"], (req, res) => {
|
||||
res.json(spec);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user