Archived
2

styled swagger

This commit is contained in:
VLE2FE
2020-04-29 15:07:07 +02:00
parent 600385cede
commit 2f0d2f2276
3 changed files with 476 additions and 1 deletions

View File

@ -48,6 +48,9 @@ app.use('/', require('./routes/root'));
app.use('/', require('./routes/user'));
app.use('/', require('./routes/material'));
// static files
app.use('/static', express.static('static'));
// Swagger UI
let apiDoc: JSONSchema = {};
jsonRefParser.bundle('api/api.yaml', (err, doc) => {
@ -56,7 +59,7 @@ jsonRefParser.bundle('api/api.yaml', (err, doc) => {
apiDoc.paths = apiDoc.paths.allOf.reduce((s, e) => Object.assign(s, e));
swagger.setup(apiDoc, {defaultModelsExpandDepth: -1, customCss: '.swagger-ui .topbar { display: none }'});
});
app.use('/api', swagger.serve, swagger.setup(apiDoc, {defaultModelsExpandDepth: -1, customCss: '.swagger-ui .topbar { display: none }'}));
app.use('/api', swagger.serve, swagger.setup(apiDoc, {customCssUrl: '/static/styles/swagger.css'}));
app.use((req, res) => { // 404 error handling
res.status(404).json({status: 'Not found'});