22 lines
488 B
JavaScript
22 lines
488 B
JavaScript
|
const swaggerJSDoc = require('swagger-jsdoc');
|
||
|
const swaggerUi = require('swagger-ui-express');
|
||
|
|
||
|
const options = {
|
||
|
definition: {
|
||
|
openapi: '3.0.0',
|
||
|
info: {
|
||
|
title: 'Books API',
|
||
|
version: '1.0.0',
|
||
|
description: 'API for managing books',
|
||
|
},
|
||
|
},
|
||
|
apis: ['./src/routes/*.js'],
|
||
|
};
|
||
|
|
||
|
const swaggerSpec = swaggerJSDoc(options);
|
||
|
|
||
|
const setupSwagger = (app) => {
|
||
|
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));
|
||
|
};
|
||
|
|
||
|
module.exports = setupSwagger;
|