-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathswagger.js
More file actions
121 lines (118 loc) · 3.24 KB
/
swagger.js
File metadata and controls
121 lines (118 loc) · 3.24 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const swaggerJsDoc = require('swagger-jsdoc');
const swaggerUi = require('swagger-ui-express');
// Swagger definition
const swaggerOptions = {
definition: {
openapi: '3.0.0',
info: {
title: 'SytSaS API',
version: '1.0.0',
description: 'API for SytSaS - Gym Management System',
contact: {
name: 'API Support',
email: 'support@sytsas.com'
},
license: {
name: 'ISC',
url: 'https://opensource.org/licenses/ISC'
}
},
servers: [
{
url: 'http://localhost:3000',
description: 'Development server'
}
],
components: {
securitySchemes: {
bearerAuth: {
type: 'http',
scheme: 'bearer',
bearerFormat: 'JWT'
}
},
schemas: {
User: {
type: 'object',
required: ['username', 'email', 'password'],
properties: {
username: {
type: 'string',
description: 'User username'
},
email: {
type: 'string',
format: 'email',
description: 'User email address'
},
password: {
type: 'string',
format: 'password',
description: 'User password (min 6 characters)'
},
role: {
type: 'string',
enum: ['user', 'admin', 'manager'],
description: 'User role'
}
}
},
Member: {
type: 'object',
required: ['nom', 'prenom', 'email', 'telephone', 'num_membre'],
properties: {
nom: {
type: 'string',
description: 'Member last name'
},
prenom: {
type: 'string',
description: 'Member first name'
},
email: {
type: 'string',
format: 'email',
description: 'Member email address'
},
telephone: {
type: 'string',
description: 'Member phone number'
},
adresse: {
type: 'object',
properties: {
rue: { type: 'string' },
ville: { type: 'string' },
codePostal: { type: 'string' },
pays: { type: 'string' }
}
},
num_membre: {
type: 'string',
description: 'Member ID number'
},
poids: {
type: 'number',
description: 'Member weight in kg'
},
taille: {
type: 'number',
description: 'Member height in cm'
},
objectif: {
type: 'string',
enum: ['Perte de poids', 'Prise de masse', 'Remise en forme', 'Compétition', 'Autre'],
description: 'Member fitness goal'
}
}
}
// Add more schemas as needed
}
}
},
apis: ['./routes/*.js', './controllers/*.js'] // Path to the API docs
};
const swaggerDocs = swaggerJsDoc(swaggerOptions);
module.exports = (app) => {
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocs));
};