-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswagger.js
More file actions
29 lines (25 loc) · 787 Bytes
/
swagger.js
File metadata and controls
29 lines (25 loc) · 787 Bytes
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
const swaggerJsdoc = require("swagger-jsdoc");
const swaggerUi = require("swagger-ui-express");
// Swagger definition
const options = {
definition: {
openapi: "3.0.0",
info: {
title: "My Node.js API",
version: "1.0.0",
description: "API documentation for my Express.js application",
},
servers: [
{
url: "http://localhost:5000",
description: "Development server",
},
],
},
apis: ["./Routes/*.js"], // Path to API route files
};
const swaggerSpec = swaggerJsdoc(options);
const setupSwagger = (app) => {
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
};
module.exports = setupSwagger;