Archived
2

splitted oas.yaml

This commit is contained in:
VLE2FE
2020-04-21 10:53:07 +02:00
parent 54e01a3320
commit 5e22afd27d
16 changed files with 1167 additions and 1137 deletions

View File

@ -2,7 +2,7 @@ import cfenv from 'cfenv';
import express from 'express';
import mongoose from 'mongoose';
import swagger from 'swagger-ui-express';
import yaml from 'yamljs';
import jsonRefParser, {JSONSchema} from '@apidevtools/json-schema-ref-parser';
// tell if server is running in debug or production environment
@ -44,14 +44,14 @@ const port = process.env.PORT || 3000;
app.use('/', require('./routes/root'));
// Swagger UI
app.use('/api', swagger.serve, swagger.setup(
yaml.load('./oas.yaml'),
{
defaultModelsExpandDepth: -1,
customCss: '.swagger-ui .topbar { display: none }'
}
)
);
let oasDoc: JSONSchema = {};
jsonRefParser.bundle('oas/oas.yaml', (err, doc) => {
if(err) throw err;
oasDoc = doc;
oasDoc.paths = oasDoc.paths.allOf.reduce((s, e) => Object.assign(s, e));
swagger.setup(oasDoc, {defaultModelsExpandDepth: -1, customCss: '.swagger-ui .topbar { display: none }'});
});
app.use('/api', swagger.serve, swagger.setup(oasDoc, {defaultModelsExpandDepth: -1, customCss: '.swagger-ui .topbar { display: none }'}));
// hook up server to port
app.listen(port, () => {