-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathswagger.json
More file actions
544 lines (544 loc) · 13.3 KB
/
Copy pathswagger.json
File metadata and controls
544 lines (544 loc) · 13.3 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "My API",
"description": "A description of my API",
"license": {
"name": "MIT",
"url": "https://opensource.org/licenses/MIT"
}
},
"host": "localhost:8080",
"basePath": "/",
"tags": [
{
"name": "Users",
"description": "API for users in the system"
},
{
"name": "Courses",
"description": "API for courses in the system"
},
{
"name": "Favourite Courses",
"description": "API for favorite courses in the system"
},
{
"name": "Rating Courses",
"description": "API for rating courses in the system"
}
],
"schemes": ["http"],
"consumes": ["application/json"],
"produces": ["application/json"],
"paths": {
"/api/users": {
"post": {
"tags": [
"Users"
],
"summary": "Create a new user",
"description": "Adds a new user to the system",
"parameters": [
{
"name": "user",
"in": "body",
"description": "User to be added",
"required": true,
"schema": {
"$ref": "#/definitions/User"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/User"
}
}
}
},
"get": {
"tags": [
"Users"
],
"summary": "Get all users",
"description": "Returns a list of all users in the system",
"parameters": [
{
"name": "nome",
"in": "query",
"description": "Filter users by name (optional)",
"type": "string"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/User"
}
}
}
}
}
},
"/api/users/{utente_id}/courses": {
"get": {
"tags": [
"Users"
],
"summary": "Get all courses for a specific user",
"description": "Returns a list of all courses for the specified user",
"parameters": [
{
"name": "utente_id",
"in": "path",
"description": "User ID",
"required": true,
"type": "string"
},
{
"name": "nome",
"in": "query",
"description": "Filter courses by name (optional)",
"type": "string"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Course"
}
}
}
}
}
},
"/api/courses": {
"post": {
"tags": [
"Courses"
],
"summary": "Create a new course",
"description": "Adds a new course to the system",
"parameters": [
{
"name": "course",
"in": "body",
"description": "Course to be added",
"required": true,
"schema": {
"$ref": "#/definitions/Course"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/Course"
}
}
}
},
"get": {
"tags": [
"Courses"
],
"summary": "Get all course",
"description": "Returns a list of all course in the system",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Course"
}
}
}
},
"delete": {
"tags": [
"Courses"
],
"summary": "Delete all courses",
"description": "Deletes all courses in the system",
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/api/courses/{id}": {
"get": {
"tags": [
"Courses"
],
"summary": "Get a single course",
"description": "Returns a course with the specified id",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Course id",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Course"
}
}
}
},
"delete": {
"tags": [
"Courses"
],
"summary": "Delete a course with id",
"description": "Deletes a course with the specified id",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Course id",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "OK"
}
}
},
"put": {
"tags": [
"Courses"
],
"summary": "Update a course with id",
"description": "Updates a course with the specified id",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Course id",
"required": true,
"type": "string"
},
{
"name": "course",
"in": "body",
"description": "Updated course",
"required": true,
"schema": {
"$ref": "#/definitions/Course"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Course"
}
}
}
}
},
"/api/courses/{id}/{utente_id}": {
"get": {
"tags": [
"Courses"
],
"summary": "Get a single course with favorite information",
"description": "Returns a course with the specified id and favorite information for the specified user",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Course id",
"required": true,
"type": "string"
},
{
"name": "utente_id",
"in": "path",
"description": "User id",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Course"
}
}
}
}
},
"/api/users/{utente_id}/courses/{nome}": {
"get": {
"tags": [
"Users"
],
"summary": "Get a specific course for a user by name",
"description": "Returns the specified course for the specified user, filtered by name",
"parameters": [
{
"name": "utente_id",
"in": "path",
"description": "User ID",
"required": true,
"type": "string"
},
{
"name": "nome",
"in": "path",
"description": "Course name",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Course"
}
}
}
}
},
"/api/users/{utente_id}/fav_courses": {
"get": {
"tags": [
"Users"
],
"summary": "Get all favourite courses for a specific user",
"description": "Returns a list of all favourite courses for the specified user",
"parameters": [
{
"name": "utente_id",
"in": "path",
"description": "User ID",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Course"
}
}
}
}
}
},
"/api/favourite_courses": {
"post": {
"tags": [
"Favourite Courses"
],
"summary": "Create a new favourite course",
"description": "Adds a new favourite course to the system",
"parameters": [
{
"name": "favourite_course",
"in": "body",
"description": "Favourite course to be added",
"required": true,
"schema": {
"$ref": "#/definitions/Favourite_course"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/Favourite_course"
}
}
}
}
},
"/api/favourite_courses/{utente_id}/{corso_id}": {
"delete": {
"tags": [
"Favourite Courses"
],
"summary": "Delete a favourite course",
"description": "Deletes a favourite course with the specified user id and course id",
"parameters": [
{
"name": "utente_id",
"in": "path",
"description": "User id",
"required": true,
"type": "string"
},
{
"name": "corso_id",
"in": "path",
"description": "Course id",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/api/rating_course": {
"post": {
"tags": ["Rating Courses"],
"summary": "Create a new rating_course",
"description": "Creates a new rating_course and saves it to the database",
"parameters": [
{
"name": "utente_id",
"in": "query",
"description": "ID of the user",
"required": true,
"type": "string"
},
{
"name": "corso_id",
"in": "query",
"description": "ID of the course",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "Successfully created the rating_course",
"schema": {
"$ref": "#/definitions/Rating_course"
}
},
"400": {
"description": "Missing required fields"
},
"500": {
"description": "Error occurred while creating the rating_course"
}
}
}
},
"/api/rating_courses/{utente_id}/{corso_id}": {
"post": {
"tags": ["Rating Courses"],
"summary": "Update a rating_course",
"description": "Updates the rating of a rating_course with the specified user and course IDs",
"parameters": [
{
"name": "utente_id",
"in": "path",
"description": "ID of the user",
"required": true,
"type": "string"
},
{
"name": "corso_id",
"in": "path",
"description": "ID of the course",
"required": true,
"type": "string"
},
{
"name": "valutazione",
"in": "body",
"description": "New rating for the rating_course",
"required": true,
"schema": {
"$ref": "#/definitions/Rating_course"
}
}
],
"responses": {
"200": {
"description": "Successfully updated the rating_course",
"schema": {
"$ref": "#/definitions/Rating_course"
}
},
"500": {
"description": "Error updating rating_course"
}
}
}
}
},
"definitions": {
"User": {
"required": [
"nome",
"cognome"
],
"properties": {
"nome":{"type": "string"},
"cognome":{"type": "string"}
}
},
"Course": {
"required": [
"nome",
"numero_cfu",
"valutazione_corso",
"attivo",
"utente_id"
],
"properties": {
"nome":{"type": "string"},
"numero_cfu":{"type": "integer"},
"valutazione_corso":{"type": "integer"},
"attivo":{"type": "boolean"},
"utente_id":{"type": "object"}
}
},
"Favourite_course": {
"required": [
"utente_id",
"corso_id"
],
"properties": {
"utente_id":{"type": "string"},
"corso_id":{"type": "string"}
}
},
"Rating_course": {
"required": [
"utente_id",
"corso_id",
"valutazione"
],
"properties": {
"utente_id":{"type": "string"},
"corso_id":{"type": "string"},
"valutazione":{"type": "integer"}
}
}
}
}