· 6 years ago · Dec 16, 2019, 09:38 PM
1
2swagger: '2.0'
3info:
4 description: |
5 This is where you can find all the User Stories we created
6 [Google Sheet](https://docs.google.com/spreadsheets/d/1qIuBUrLQgBTlntmr3HLEKPQhXrZkuE8ijw9zai3r7zg/edit?usp=sharing)
7 If you want to log as a guard use this API key: aaaR2lhbmx1aWdpIGlsIGJlbGxv
8 If you want to log as a teacher use :
9 bbbdGVra2sgdGhlIG1la2sK
10 If u want to log as a prisoner use:
11 cccYWxiZXJ0byBpbCBub24gY2VydG8
12 version: 1.0.0
13 title: Prisoners at School
14 termsOfService: https://www.unitn.it/en/ateneo/51110/legal-information
15 contact:
16 name: Issues page
17 url: https://github.com/MattiaCarolo/SE2_Project/issues
18 email: mattia.carolo@studenti.unitn.it
19 license:
20 name: Node JS
21 url: https://github.com/nodejs/node/blob/master/LICENSE
22
23tags:
24- name: Guard
25 description: All managing tools a guard needs
26- name: Teacher
27 description: Tools to manage courses
28- name: Prisoner
29 description: Tools to let prisoners attend courses
30# schemes:
31# - https
32paths:
33 /guard/course:
34 post:
35 tags:
36 - Guard
37 summary: add new course
38 operationId: addEmptyCourse
39 produces:
40 - application/json
41 parameters:
42 - in: body
43 name: body
44 description: Empty course object (apart for name) to add to db
45 required: true
46 schema:
47 type: object
48 properties:
49 name:
50 type: string
51 example:
52 name: Balalaika
53 responses:
54 200:
55 description: Successfully added a course
56 400:
57 description: You should give a name to the course // CODE.ERR name field empty
58 security:
59 - ApiKeyAuth: []
60 patch:
61 tags:
62 - Guard
63 summary: Approve or reject a course
64 operationId: Approval
65 produces:
66 - application/json
67 parameters:
68 - in: query
69 name: name
70 description: The name of the course
71 type: string
72 required: true
73 - in: query
74 name: result
75 description: The name of the course
76 required: true
77 type: string
78 enum:
79 - true
80 - false
81 - in: query
82 name: motives
83 description: The motives leading to the rejection of the course (if it's rejected)
84 type: string
85 required: false
86 responses:
87 200:
88 description: <Course name> modified
89 400:
90 description: You should tell the teacher why the course is rejected // CODE.ERR motives field empty
91 404:
92 description: not found
93 security:
94 - ApiKeyAuth: []
95 get:
96 tags:
97 - Guard
98 summary: Finds all courses taught in jail
99 operationId: AllCourseGuard
100 produces:
101 - application/json
102# parameters:
103# - name: status
104# in: query
105# description: Status values that need to be considered for filter
106# required: true
107# type: array
108# items:
109# type: string
110# enum:
111# - pending_approval
112# - approved
113# - rejected
114# - all
115# default: all
116# collectionFormat: multi
117 responses:
118 200:
119 description: successful operation
120 schema:
121 type: array
122 items:
123 $ref: '#/definitions/Course'
124 security:
125 - ApiKeyAuth: []
126 delete:
127 tags:
128 - Guard
129 summary: Deletes a course
130 operationId: deleteCourseFinal
131 produces:
132 - application/json
133 parameters:
134 - name: name
135 in: query
136 description: name of the course to return
137 required: true
138 type: string
139 responses:
140 200:
141 description: course successfully deleted from DB
142 404:
143 description: course not found or already deleted (maybe update course list)
144 security:
145 - ApiKeyAuth: []
146
147 /guard/course/{name}:
148 get:
149 tags:
150 - Guard
151 summary: Find course by name
152 description: Returns a single pet
153 operationId: FindCourseGuard
154 produces:
155 - application/json
156 parameters:
157 - name: name
158 in: path
159 description: name of course to return
160 required: true
161 type: string
162 responses:
163 200:
164 description: successful operation
165 schema:
166 type: array
167 items:
168 $ref: '#/definitions/Course'
169 404:
170 description: Course not found // CODE.ERR the desired course < course name > was not on our list of courses
171 security:
172 - ApiKeyAuth: []
173
174 /teacher/course/{name}:
175 get:
176 tags:
177 - Teacher
178 summary: Find course by name
179 description: Returns the searched course
180 operationId: FindCourseTeacher
181 produces:
182 - application/json
183 parameters:
184 - name: name
185 in: path
186 description: name of course to return
187 required: true
188 type: string
189 responses:
190 200:
191 description: successful operation
192 schema:
193 type: array
194 items:
195 $ref: '#/definitions/Course'
196
197 security:
198 - ApiKeyAuth: []
199
200 /teacher/course:
201 post:
202 tags:
203 - Teacher
204 summary: add new course with name, description and teacher
205 operationId: addCourseByTeacher
206 produces:
207 - application/json
208 parameters:
209 - in: body
210 name: body
211 description: Course with name, description and teacher
212 required: true
213 schema:
214 type: object
215 properties:
216 name:
217 type: string
218 desc:
219 type: string
220 teac:
221 type: string
222 example:
223 name: Name
224 desc: Description
225 teac: Teacher
226 responses:
227 200:
228 description: Successfully added a course
229 400:
230 description: Course name Already on the list of courses
231 security:
232 - ApiKeyAuth: []
233
234 delete:
235 tags:
236 - Teacher
237 summary: Deletes a course
238 operationId: deleteCourseByTeacher
239 produces:
240 - application/json
241 parameters:
242 - name: name
243 in: query
244 description: name of the course to delete
245 required: true
246 type: string
247 responses:
248 200:
249 description: course successfully deleted from DB
250 404:
251 description: course not found or already deleted (maybe update course list)
252 security:
253 - ApiKeyAuth: []
254
255 patch:
256 tags:
257 - Teacher
258 summary: Change description, teacher and calendar of a course
259 operationId: editCourse
260 produces:
261 - application/json
262 parameters:
263 - in: query
264 name: name
265 description: The name of the course you want to edit
266 type: string
267 required: true
268 - in: query
269 name: desc
270 description: The new description of the course
271 required: true
272 type: string
273 - in: query
274 name: teac
275 description: The new teacher of the course
276 type: string
277 required: true
278 - in: query
279 name: calendar
280 description: The new calendar of the course
281 type: string
282 required: true
283 responses:
284 200:
285 description: course edited succesfully
286 404:
287 description: not found
288 security:
289 - ApiKeyAuth: []
290
291 /course/calendar:
292 post:
293 tags:
294 - Teacher
295 summary: Add all calendars to a course
296 operationId: crateAllCalendars
297 produces:
298 - application/json
299 parameters:
300 - in: body
301 name: calendar
302 description: all the calendars
303 required: true
304 schema:
305 type: array
306 items:
307 $ref: '#/definitions/Calendar1'
308
309 responses:
310 200:
311 description: Successfully added all the calendars
312 400:
313 description: calendars already present
314 security:
315 - ApiKeyAuth: []
316
317 /course/calendar/{id}:
318
319 get:
320 tags:
321 - Teacher
322 summary: Return calendars of a course
323 description: Returns the searched calendars
324 operationId: getCalendarByCourse
325 produces:
326 - application/json
327 parameters:
328 - name: id
329 in: path
330 description: id of course
331 required: true
332 type: integer
333 responses:
334 200:
335 description: successful operation
336 schema:
337 type: array
338 items:
339 $ref: '#/definitions/Calendar1'
340 security:
341 - ApiKeyAuth: []
342
343#manca la post con richiesta sianell'url che nel body err.oneOf
344
345 delete:
346 tags:
347 - Teacher
348 summary: remove all calendars
349 operationId: deleteAllCalendar
350 produces:
351 - application/json
352 parameters:
353 - name: id
354 in: path
355 description: idcourse of the calendars to delete
356 required: true
357 type: integer
358 responses:
359 200:
360 description: calendars successfully deleted from DB
361 404:
362 description: calendars not found or already deleted (maybe update course list)
363 security:
364 - ApiKeyAuth: []
365
366 /course/calendar/{id}/{name}:
367 delete:
368 tags:
369 - Teacher
370 summary: Delete one calendar by name
371 operationId: deleteCalendarByName
372 produces:
373 - application/json
374 parameters:
375 - name: id
376 in: path
377 description: id of the course with the calendar to delete
378 required: true
379 type: integer
380 - name: name
381 in: path
382 description: name of the calendar to delete
383 required: true
384 type: string
385 responses:
386 200:
387 description: calendar successfully deleted from DB
388 404:
389 description: calendar not found or already deleted (maybe update course list)
390 security:
391 - ApiKeyAuth: []
392
393
394 put:
395 tags:
396 - Teacher
397 summary: Modify a calendar of a course
398 operationId: modifyCalendarByName
399 produces:
400 - application/json
401 parameters:
402 - name: id
403 in: path
404 description: id of the course with the calendar to modify
405 required: true
406 type: integer
407 - name: name
408 in: path
409 description: name of the calendar to modify
410 required: true
411 type: string
412 #manca da richiedere il calendario nel body
413 responses:
414 200:
415 description: successful operation
416 404:
417 description: calendar not found
418
419 security:
420 - ApiKeyAuth: []
421
422securityDefinitions:
423 ApiKeyAuth:
424 type: apiKey
425 in: header
426 name: key
427
428definitions:
429
430 Calendar:
431 type: object
432 properties:
433 id:
434 type: integer
435 format: int64
436 name:
437 type: string
438 xml:
439 name: calendar
440
441 Calendar1:
442 type: object
443 properties:
444 idcourse:
445 type: integer
446 calendar:
447 type: array
448 items:
449 $ref: '#/definitions/Calendar2'
450 xml:
451 name: Calendar1
452
453 Calendar2:
454 type: object
455 properties:
456 name:
457 type: string
458 example: esperto
459 lunedi:
460 type: string
461 example: 10:30 - 12:30
462 martedi:
463 type: string
464 example: 9:30 - 12:30
465 mercoledi:
466 type: string
467 example: 10:30 - 13:30
468 giovedi:
469 type: string
470 example: 17:30 - 19:30
471 venerdi:
472 type: string
473 example: 15:30 - 17:30
474 xml:
475 name: Calendar2
476
477 Showcase:
478 type: object
479 properties:
480 id:
481 type: integer
482 format: int64
483 name:
484 type: string
485 xml:
486 name: calendar
487
488 Prisoner:
489 type: object
490 properties:
491 name:
492 type: string
493 SSN:
494 type: string
495 Danger_level:
496 type: string
497 description: Danger level of the prisoner
498 enum:
499 - low
500 - medium
501 - high
502 - quarantine
503 xml:
504 name: prisoners
505 Course:
506 type: object
507 required:
508 - name
509 properties:
510 name:
511 type: string
512 example: Scacchi
513 description:
514 type: string
515 example: Sono scacchi che ti aspettavi
516 pending_approval:
517 type: boolean
518 example: false
519 approved:
520 type: boolean
521 example: false
522 teacher:
523 type: string
524 example: Anatoly Karpov
525 students:
526 type: array
527 items:
528 $ref: '#/definitions/Prisoner'
529 reject_motives:
530 type: string
531 example: Not enough students
532 calendar:
533 $ref: '#/definitions/Calendar'
534 showcase:
535 $ref: '#/definitions/Showcase'
536 xml:
537 name: Course
538 ApiResponse:
539 type: object
540 properties:
541 description:
542 type: string
543 example: You should tell the teacher why the course is rejected // CODE.ERR motives field empty
544 code:
545 type: integer
546 format: int32
547 example: 400
548host: prisoners-at-school.herokuapp.com
549basePath: /api
550schemes:
551 - https