· 5 years ago · Mar 23, 2020, 08:28 PM
1openapi: 3.0.0
2info:
3 title: Project-X
4 contact: {}
5 version: '1.0'
6paths:
7 /oauth/token:
8 post:
9 tags:
10 - User
11 summary: Get bearer token
12 operationId: GetToken
13 parameters:
14 - name: Content-Type
15 in: header
16 required: true
17 style: simple
18 schema:
19 type: string
20 example: application/x-www-form-urlencoded
21 requestBody:
22 content:
23 application/x-www-form-urlencoded:
24 encoding: {}
25 schema:
26 required:
27 - grant_type
28 - username
29 - password
30 type: object
31 properties:
32 grant_type:
33 type: string
34 example: password
35 username:
36 type: string
37 example: username
38 password:
39 type: string
40 example: password
41 required: true
42 x-send-file-in-body: false
43 responses:
44 200:
45 description: 'Response with valid granted token'
46 headers: {}
47 content:
48 application/json:
49 schema:
50 $ref: '#/components/schemas/TokenResponse'
51 400:
52 description: 'Invalid credentials'
53 content:
54 application/json:
55 schema:
56 $ref: '#/components/schemas/ErrorResponseOauth'
57 deprecated: false
58 security: [{}]
59 /user/create:
60 post:
61 tags:
62 - User
63 summary: Create user
64 operationId: Createuser
65 parameters:
66 - name: Content-Type
67 in: header
68 required: true
69 style: simple
70 schema:
71 type: string
72 example: application/json
73 requestBody:
74 content:
75 application/json:
76 schema:
77 $ref: '#/components/schemas/CreateuserRequest'
78 example:
79 username: string
80 password: string
81 email: string
82 required: true
83 x-send-file-in-body: false
84 responses:
85 200:
86 description: 'user has been created'
87 headers: {}
88 content:
89 application/json:
90 schema:
91 $ref: '#/components/schemas/CreatedUserResponseOk'
92 400:
93 description: 'user already exists'
94 content:
95 application/json:
96 schema:
97 $ref: '#/components/schemas/ErrorResponse'
98 deprecated: false
99 security: [{}]
100 /user/password:
101 post:
102 tags:
103 - User
104 summary: Change password
105 operationId: Changepassword
106 parameters: []
107 requestBody:
108 content:
109 application/json:
110 schema:
111 $ref: '#/components/schemas/ChangepasswordRequest'
112 example:
113 oldPassword: adminadmin
114 newPassword: zaq1@WSX
115 required: true
116 x-send-file-in-body: false
117 responses:
118 200:
119 description: ''
120 headers: {}
121 deprecated: false
122 /user/all:
123 get:
124 tags:
125 - User
126 summary: List of users
127 operationId: Listofusers
128 parameters: []
129 responses:
130 200:
131 description: ''
132 headers: {}
133 deprecated: false
134 /location/create:
135 post:
136 tags:
137 - Location
138 summary: Create Location
139 operationId: CreateLocation
140 parameters: []
141 requestBody:
142 content:
143 application/json:
144 schema:
145 $ref: '#/components/schemas/CreateLocationRequest'
146 example:
147 name: Jagiellonium Universitetum
148 description: Uniwersytet Jagielloński
149 roles:
150 - name: Arechologia
151 description: XDDDD
152 - name: Prawo
153 description: Crossfit
154 required: true
155 x-send-file-in-body: false
156 responses:
157 200:
158 description: ''
159 headers: {}
160 deprecated: false
161 /location/my_locations:
162 get:
163 tags:
164 - Location
165 summary: List of all user's locations
166 operationId: Listofalluser'slocations
167 parameters: []
168 responses:
169 200:
170 description: ''
171 headers: {}
172 deprecated: false
173 /location/5d9bb4c3a7b11b0001d2adab:
174 get:
175 tags:
176 - Location
177 summary: Get location by ID
178 operationId: GetlocationbyID
179 parameters: []
180 responses:
181 200:
182 description: ''
183 headers: {}
184 deprecated: false
185 delete:
186 tags:
187 - Location
188 summary: Delete location by ID
189 operationId: DeletelocationbyID
190 parameters: []
191 responses:
192 200:
193 description: ''
194 headers: {}
195 deprecated: false
196 /location/5d8bb73f6344590001feffd3:
197 put:
198 tags:
199 - Location
200 summary: Edit location
201 operationId: Editlocation
202 parameters: []
203 requestBody:
204 content:
205 application/json:
206 schema:
207 $ref: '#/components/schemas/EditlocationRequest'
208 example:
209 name: Jagiellonium Universitetum
210 description: Wariaty
211 roles:
212 - name: a
213 description: idiota
214 - name: Prawo
215 description: Edit
216 - name: Prof 3
217 description: idiota3
218 required: true
219 x-send-file-in-body: false
220 responses:
221 200:
222 description: ''
223 headers: {}
224 deprecated: false
225 /game/create:
226 post:
227 tags:
228 - Game
229 summary: Create game
230 operationId: Creategame
231 parameters:
232 - name: Content-Type
233 in: header
234 required: true
235 style: simple
236 schema:
237 type: string
238 example: application/json
239 - name: Authorization
240 in: header
241 required: true
242 style: simple
243 schema:
244 type: string
245 example: Bearer {token}
246 requestBody:
247 content:
248 application/json:
249 schema:
250 $ref: '#/components/schemas/CreategameRequest'
251 example:
252 location:
253 id: "string"
254 required: true
255 x-send-file-in-body: false
256 responses:
257 200:
258 description: 'game has been created'
259 content:
260 application/json:
261 schema:
262 $ref: '#/components/schemas/GameResponseOk'
263
264 400:
265 description: 'Invalid properties'
266 content:
267 application/json:
268 schema:
269 $ref: '#/components/schemas/ErrorResponse'
270 401:
271 description: 'Invalid token'
272 content:
273 application/json:
274 schema:
275 $ref: '#/components/schemas/ErrorResponseOauth'
276 404:
277 description: 'resource has not been found'
278 content:
279 application/json:
280 schema:
281 $ref: '#/components/schemas/ErrorResponse'
282 500:
283 description: 'Database error'
284 content:
285 application/json:
286 schema:
287 $ref: '#/components/schemas/ErrorResponse'
288
289 deprecated: false
290 /game/all:
291 get:
292 tags:
293 - Game
294 summary: Get list of games
295 operationId: Getlistofgames
296 parameters:
297 - name: Authorization
298 in: header
299 required: true
300 style: simple
301 schema:
302 type: string
303 example: Bearer {token}
304 responses:
305 200:
306 description: 'list of existing games'
307 content:
308 application/json:
309 schema:
310 $ref: '#/components/schemas/GameListResponseOk'
311 401:
312 description: 'Invalid token'
313 content:
314 application/json:
315 schema:
316 $ref: '#/components/schemas/ErrorResponseOauth'
317 403:
318 description: 'action forbidden'
319 content:
320 application/json:
321 schema:
322 $ref: '#/components/schemas/ErrorResponseOauth'
323 deprecated: false
324 /game/all/user:
325 get:
326 tags:
327 - Game
328 summary: Get list of user games
329 operationId: Getlistofusergames
330 parameters:
331 - name: Authorization
332 in: header
333 required: true
334 style: simple
335 schema:
336 type: string
337 example: Bearer {token}
338 responses:
339 200:
340 description: 'user games found'
341 content:
342 application/json:
343 schema:
344 $ref: '#/components/schemas/GameListResponseOk'
345 401:
346 description: 'Invalid token'
347 content:
348 application/json:
349 schema:
350 $ref: '#/components/schemas/ErrorResponseOauth'
351 500:
352 description: 'Database error'
353 content:
354 application/json:
355 schema:
356 $ref: '#/components/schemas/ErrorResponse'
357
358 deprecated: false
359 /game/{gameId}:
360 get:
361 tags:
362 - Game
363 summary: Get game by ID
364 operationId: GetgamebyID
365 parameters:
366 - name: Authorization
367 in: header
368 required: true
369 style: simple
370 schema:
371 type: string
372 example: Bearer {token}
373 - in: path
374 name: gameId
375 required: true
376 schema:
377 type: string
378 description: Id of the game
379 example: Game ID
380 responses:
381 200:
382 description: 'game of corresponding id has been found'
383 content:
384 application/json:
385 schema:
386 $ref: '#/components/schemas/GameResponseOk'
387 401:
388 description: 'Invalid token'
389 content:
390 application/json:
391 schema:
392 $ref: '#/components/schemas/ErrorResponseOauth'
393 403:
394 description: 'action forbidden'
395 content:
396 application/json:
397 schema:
398 $ref: '#/components/schemas/ErrorResponseOauth'
399
400 404:
401 description: 'resource has not been found'
402 content:
403 application/json:
404 schema:
405 $ref: '#/components/schemas/ErrorResponse'
406 500:
407 description: 'Database error'
408 content:
409 application/json:
410 schema:
411 $ref: '#/components/schemas/ErrorResponse'
412
413 deprecated: false
414 /game/start/{gameId}:
415 get:
416 tags:
417 - Game
418 summary: Get started game by ID for player
419 operationId: GetfinishedgamebyID
420 parameters:
421 - in: path
422 name: gameId
423 required: true
424 schema:
425 type: string
426 description: Id of the game
427 example: Game ID
428 - name: Authorization
429 in: header
430 required: true
431 style: simple
432 schema:
433 type: string
434 example: Bearer {token}
435 responses:
436 200:
437 description: 'Info about the game for player'
438 content:
439 application/json:
440 schema:
441 $ref: '#/components/schemas/GameInfoOk'
442
443 401:
444 description: 'Invalid token'
445 content:
446 application/json:
447 schema:
448 $ref: '#/components/schemas/ErrorResponseOauth'
449 403:
450 description: 'action forbidden'
451 content:
452 application/json:
453 schema:
454 $ref: '#/components/schemas/ErrorResponseOauth'
455
456 404:
457 description: 'resource has not been found'
458 content:
459 application/json:
460 schema:
461 $ref: '#/components/schemas/ErrorResponse'
462 500:
463 description: 'Database error'
464 content:
465 application/json:
466 schema:
467 $ref: '#/components/schemas/ErrorResponse'
468 deprecated: false
469 /game/join/{gameId}:
470 put:
471 tags:
472 - Game
473 summary: Add new player to game
474 operationId: Addnewplayertogame
475 parameters:
476 - name: Content-Type
477 in: header
478 required: true
479 style: simple
480 schema:
481 type: string
482 example: application/json
483 - name: Authorization
484 in: header
485 required: true
486 style: simple
487 schema:
488 type: string
489 example: Bearer {token}
490 - in: path
491 name: gameId
492 required: true
493 schema:
494 type: string
495 description: Id of the game
496 example: Game ID
497 responses:
498 200:
499 description: ''
500 headers: {}
501 deprecated: false
502
503 /game/5dc4422163445900011814d5/location/5dc441f963445900011814cf:
504 put:
505 tags:
506 - Game
507 summary: Change game location
508 operationId: Changegamelocation
509 parameters:
510 - name: Content-Type
511 in: header
512 required: true
513 style: simple
514 schema:
515 type: string
516 example: application/json
517 responses:
518 200:
519 description: ''
520 headers: {}
521 deprecated: false
522 /game/start/5e778462a7b11b0001612e8a:
523 put:
524 tags:
525 - Game
526 summary: Start Game
527 operationId: StartGame
528 parameters:
529 - name: Content-Type
530 in: header
531 required: true
532 style: simple
533 schema:
534 type: string
535 example: application/json
536 responses:
537 200:
538 description: ''
539 headers: {}
540 deprecated: false
541 /game/finish/5e778462a7b11b0001612e8a:
542 put:
543 tags:
544 - Game
545 summary: Finish Game
546 operationId: FinishGame
547 parameters:
548 - name: Content-Type
549 in: header
550 required: true
551 style: simple
552 schema:
553 type: string
554 example: application/json
555 responses:
556 200:
557 description: ''
558 headers: {}
559 deprecated: false
560 /game/5e778462a7b11b0001612e8a:
561 delete:
562 tags:
563 - Game
564 summary: Delete game by ID
565 operationId: DeletegamebyID
566 parameters: []
567 responses:
568 200:
569 description: ''
570 headers: {}
571 deprecated: false
572components:
573 schemas:
574 CreateuserRequest:
575 title: CreateuserRequest
576 required:
577 - username
578 - password
579 - email
580 type: object
581 properties:
582 username:
583 type: string
584 description: 'min length: 5'
585 password:
586 type: string
587 description: 'min length: 8'
588 email:
589 type: string
590 description: 'valid email'
591 example:
592 username: string
593 password: string
594 email: string
595 ChangepasswordRequest:
596 title: ChangepasswordRequest
597 required:
598 - oldPassword
599 - newPassword
600 type: object
601 properties:
602 oldPassword:
603 type: string
604 newPassword:
605 type: string
606 example:
607 oldPassword: adminadmin
608 newPassword: zaq1@WSX
609 CreateLocationRequest:
610 title: CreateLocationRequest
611 required:
612 - name
613 - description
614 - roles
615 type: object
616 properties:
617 name:
618 type: string
619 description:
620 type: string
621 roles:
622 type: array
623 items:
624 $ref: '#/components/schemas/Role'
625 example:
626 name: Jagiellonium Universitetum
627 description: Uniwersytet Jagielloński
628 roles:
629 - name: Arechologia
630 description: XDDDD
631 - name: Prawo
632 description: Crossfit
633 Role:
634 title: Role
635 required:
636 - name
637 - description
638 type: object
639 properties:
640 name:
641 type: string
642 description:
643 type: string
644 example:
645 name: Arechologia
646 description: XDDDD
647 EditlocationRequest:
648 title: EditlocationRequest
649 required:
650 - name
651 - description
652 - roles
653 type: object
654 properties:
655 name:
656 type: string
657 description:
658 type: string
659 roles:
660 type: array
661 items:
662 $ref: '#/components/schemas/Role'
663 example:
664 name: Jagiellonium Universitetum
665 description: Wariaty
666 roles:
667 - name: a
668 description: idiota
669 - name: Prawo
670 description: Edit
671 - name: Prof 3
672 description: idiota3
673 CreateUJlocationRequest:
674 title: CreateUJlocationRequest
675 required:
676 - name
677 - description
678 - roles
679 type: object
680 properties:
681 name:
682 type: string
683 description:
684 type: string
685 roles:
686 type: array
687 items:
688 $ref: '#/components/schemas/Role'
689 example:
690 name: Jagiellonium Universitetum
691 description: Uniwersytet Jagielloński
692 roles:
693 - name: Arechologia
694 description: XDDDD
695 - name: Prawo
696 description: Crossfit
697 CreateotherlocationRequest:
698 title: CreateotherlocationRequest
699 required:
700 - name
701 - description
702 - roles
703 type: object
704 properties:
705 name:
706 type: string
707 description:
708 type: string
709 roles:
710 type: array
711 items:
712 $ref: '#/components/schemas/Role'
713 example:
714 name: Comarch
715 description: McDonald dla Programistow XDD
716 roles:
717 - name: Janusz
718 description: XDDDD
719 - name: Kumarch
720 description: staz
721 - name: Cos
722 description: trzecie
723 CreategameRequest:
724 title: CreategameRequest
725 required:
726 - location
727 type: object
728 properties:
729 location:
730 $ref: '#/components/schemas/Location'
731 example:
732 location:
733 id: 55e778446a7b11b0001612e89
734 Location:
735 title: Location
736 required:
737 - id
738 type: object
739 properties:
740 id:
741 type: string
742 example:
743 id: 55e778446a7b11b0001612e89
744 CreatenewuserRequest:
745 title: CreatenewuserRequest
746 required:
747 - username
748 - password
749 - email
750 type: object
751 properties:
752 username:
753 type: string
754 password:
755 type: string
756 email:
757 type: string
758 example:
759 username: janko123
760 password: janko123
761 email: wadsars@janko.pl
762
763 TokenResponse:
764 title: Access token
765 type: object
766 properties:
767 access_token:
768 type: string
769 token_type:
770 type: string
771 expires_in:
772 type: integer
773 scope:
774 type: string
775 jti:
776 type: string
777
778 CreatedUserResponseOk:
779 title: Created user
780 type: object
781 properties:
782 type:
783 type: string
784 message:
785 type: string
786 user:
787 $ref: '#/components/schemas/UserObject'
788
789
790 UserObject:
791 title: User object
792 type: object
793 properties:
794 id:
795 type: string
796 username:
797 type: string
798 email:
799 type: string
800 authority:
801 type: string
802 enabled:
803 type: boolean
804 signedDate:
805 type: string
806 lastLogged:
807 type: string
808
809 GameResponseOk:
810 title: Created Game
811 type: object
812 properties:
813 type:
814 type: string
815 message:
816 type: string
817 game:
818 $ref: '#/components/schemas/GameObject'
819
820 GameListResponseOk:
821 title: Created Game
822 type: object
823 properties:
824 type:
825 type: string
826 message:
827 type: string
828 existingGames:
829 $ref: '#/components/schemas/ArrayOfGames'
830
831
832 GameObject:
833 title: Game Object
834 type: object
835 properties:
836 id:
837 type: string
838 host:
839 $ref: '#/components/schemas/UserObject'
840 gameTime:
841 type: string
842 location:
843 $ref: '#/components/schemas/LocationObject'
844 playersWithRoles:
845 type: object
846 properties:
847 player:
848 $ref: '#/components/schemas/RoleObject'
849
850 LocationObject:
851 title: Location Object
852 type: object
853 properties:
854 id:
855 type: string
856 name:
857 type: string
858 description:
859 type: string
860 roles:
861 $ref: '#/components/schemas/ArrayOfRoles'
862 date:
863 type: string
864
865
866 RoleObject:
867 title: Role Object
868 type: object
869 properties:
870 id:
871 type: string
872 name:
873 type: string
874 description:
875 type: string
876
877 ArrayOfRoles:
878 type: array
879 items:
880 allOf:
881 - $ref: '#/components/schemas/RoleObject'
882
883 ArrayOfGames:
884 type: array
885 items:
886 allOf:
887 - $ref: '#/components/schemas/GameObject'
888
889 ShortResponseOk:
890 title: Change ok
891 type: object
892 properties:
893 type:
894 type: string
895 message:
896 type: string
897
898 GameInfoOk:
899 title: info about the game
900 type: object
901 properties:
902 type:
903 type: string
904 message:
905 type: string
906 playerRole:
907 $ref: '#/components/schemas/RoleObject'
908 location:
909 $ref: '#/components/schemas/LocationObject'
910 date:
911 type: string
912
913 ErrorResponse:
914 title: Error response
915 type: object
916 properties:
917 type:
918 type: string
919 message:
920 type: string
921 description:
922 type: string
923 status:
924 type: string
925
926 ErrorResponseOauth:
927 title: Error oauth response
928 type: object
929 properties:
930 error:
931 type: string
932 error_description:
933 type: string
934
935
936 securitySchemes:
937 BearerAuth: # arbitrary name for the security scheme
938 type: http
939 scheme: bearer
940 bearerFormat: JWT
941
942
943security:
944 - BearerAuth: []
945tags:
946 - name: User
947 - name: Location
948 - name: Game
949 description: Endpoint requests for game service