-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswagger.js
41 lines (40 loc) · 1.08 KB
/
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
38
39
40
41
const swaggerJsdoc = require("swagger-jsdoc");
const swaggerUi = require("swagger-ui-express");
const options = {
definition: {
openapi: "3.0.0",
info: {
title: "Quotes Backend",
description: "API endpoints for a Quote demo website",
contact: {
name: "Devdutt",
email: "devdutt.c@evolutioncloud.in",
url: "https://github.com/devdutt-evolution",
},
version: "1.0.0",
},
servers: [
{
url: "http://localhost:3001/",
description: "Local server",
},
{
url: "https://card-demo-bl6n.onrender.com/",
description: "Live server",
},
],
},
// looks for configuration in specified directories
apis: ["./swagger/*.js"],
};
const swaggerSpec = swaggerJsdoc(options);
function swaggerDocs(app, port) {
// Swagger Page
app.use("/docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
// Documentation in JSON format
app.get("/docs.json", (req, res) => {
res.setHeader("Content-Type", "application/json");
res.send(swaggerSpec);
});
}
module.exports = swaggerDocs;