-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathswagger.js
37 lines (32 loc) · 883 Bytes
/
swagger.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const swaggerJsdoc = require('swagger-jsdoc');
const swaggerUi = require('swagger-ui-express');
const options = {
definition: {
openapi: '3.0.0',
info: {
title: 'Backend App API',
version: '1.0.0',
description: 'API documentation for the Backend App',
},
},
apis: ['./routes/*.js', './controllers/*.js', './models/*.js'],
};
const specs = swaggerJsdoc(options);
const swaggerOptions = {
customSiteTitle: 'Backend App API Documentation',
swaggerOptions: {
docExpansion: 'none',
defaultModelsExpandDepth: -1,
defaultModelExpandDepth: 0,
showRequestHeaders: false,
},
};
const CSS_URL =
'https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/4.1.0/swagger-ui.min.css';
module.exports = (app) => {
app.use(
'/api-docs',
swaggerUi.serve,
swaggerUi.setup(specs, swaggerOptions, { customCssUrl: CSS_URL }),
);
};