-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswagger.js
53 lines (35 loc) · 1.16 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
42
43
44
45
46
47
48
49
50
51
52
// importamos las dos depencias que acabamos de instalar
const swaggerJSDoc = require("swagger-jsdoc");
const swaggerUi = require("swagger-ui-express");
require("dotenv").config();
const options = {
definition: {
openapi: "3.0.0",
info: {
title: "Mi Eccomerce",
version: "1.0.0",
description: "API for the sale of products online of Mi Ecommerce.",
},
},
apis: [
"./src/routes/users.routes.js",
"./src/models/users.models.js",
"./src/routes/auth.routes.js",
"./src/models/auth.models.js",
"./src/routes/categories.routes.js",
"./src/models/categories.models.js",
"./src/routes/products.routes.js",
"./src/models/products.models.js",
"./src/routes/cart.routes.js",
"./src/models/cart.models.js",
"./src/models/productInCart.models.js",
"./src/routes/orders.routes.js",
"./src/models/productInOrder.models.js",
],
};
const swaggerSpec = swaggerJSDoc(options);
const swaggerDocs = (app, port) => {
app.use("/api/v1/docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
console.log(`Doc V1 disponible en ${process.env.URL}/api/v1/docs`);
};
module.exports = swaggerDocs;