-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswagger.js
More file actions
64 lines (60 loc) · 1.8 KB
/
swagger.js
File metadata and controls
64 lines (60 loc) · 1.8 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const swaggerJsdoc = require("swagger-jsdoc");
const swaggerUi = require("swagger-ui-express");
const options = {
definition: {
openapi: "3.0.0",
info: {
title: "NexWallet API",
version: "1.0.0",
},
tags: [
{ name: "Auth", description: "User Registration and Login" },
{ name: "Admin", description: "Admin Operations and Reports" },
{ name: "Wallet", description: "Wallet Operations (Deposit, Withdraw, Transfer)" }
],
components: {
securitySchemes: {
bearerAuth: {
type: "http",
scheme: "bearer",
bearerFormat: "JWT",
},
},
schemas: {
Transaction: {
type: "object",
properties: {
_id: { type: "string" },
type: { type: "string", enum: ["deposit", "withdraw", "transfer"] },
from: { type: "string", nullable: true },
to: { type: "string", nullable: true },
currency: { type: "string" },
amount: { type: "number" },
createdAt: { type: "string", format: "date-time" },
flagged: { type: "boolean" },
reason: { type: "string", nullable: true },
deleted: { type: "boolean" }
},
example: {
_id: "a7c9d523f18b49e2d4567abc",
type: "deposit",
from: null,
to: "a7c9d523f18b49e2d4567abd",
currency: "EUR",
amount: 2500,
createdAt: "2025-05-18T10:30:00Z",
flagged: false,
reason: null,
deleted: false
}
}
}
},
security: [{ bearerAuth: [] }],
},
apis: ["./routes/*.js"],
};
const specs = swaggerJsdoc(options);
module.exports = function (app) {
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(specs));
};