-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswagger.ts
More file actions
32 lines (28 loc) · 1 KB
/
swagger.ts
File metadata and controls
32 lines (28 loc) · 1 KB
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
import swaggerJsdoc from "swagger-jsdoc";
import swaggerUi from "swagger-ui-express";
import { Express } from "express";
const options: swaggerJsdoc.Options = {
definition: {
openapi: "3.0.0",
info: {
title: "Ecommerce api",
version: "1.0.0",
description: "API documentation for an Ecommerce application",
},
servers: [
{
url: "{protocol}://{host}",
description: "Current server",
protocol: { default: "https" },
host: { default: "08bc7119-064b-443d-af0f-fe48f7a05685.us-east-1.cloud.genez.io//" },
},
{ url: "http://localhost:3000", description: "Local development server" },
],
},
apis: ["./src/routes/products/*.ts", "./src/routes/auth/*.ts"], // Point to your controller files
};
const swaggerSpec = swaggerJsdoc(options);
export const setupSwagger = (app: Express) => {
app.use("/docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
console.log("Swagger docs available at /docs");
};