-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswagger.js
31 lines (27 loc) · 821 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
/* eslint-disable import/no-extraneous-dependencies */
import swaggerJsDoc from 'swagger-jsdoc';
import swaggerUi from 'swagger-ui-express';
const swaggerOptions = {
definition: {
openapi: '3.0.0',
info: {
title: 'File Manager API',
version: '1.0.0',
description: 'API documentation for the File Manager application',
},
servers: [
{ url: 'http://localhost:3000', descriptio: 'Development server' },
],
},
apis: ['./routes/*.js'],
};
// Generate swagger documentation
const swaggerDocs = swaggerJsDoc(swaggerOptions);
/**
* setup Swagger middleware for the Express app
* @param {Object} app - The Express application instance
*/
const setupSwagger = (app) => {
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocs));
};
export default setupSwagger;