· 5 years ago · Mar 23, 2020, 08:50 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 put:
470 tags:
471 - Game
472 summary: Start the game
473 operationId: StartGame
474 parameters:
475 - name: Content-Type
476 in: header
477 required: true
478 style: simple
479 schema:
480 type: string
481 example: application/json
482 - in: path
483 name: gameId
484 required: true
485 schema:
486 type: string
487 description: Id of the game
488 example: Game ID
489 responses:
490 200:
491 description: 'Game has started'
492 content:
493 application/json:
494 schema:
495 $ref: '#/components/schemas/ShortResponseOk'
496
497 401:
498 description: 'Invalid token'
499 content:
500 application/json:
501 schema:
502 $ref: '#/components/schemas/ErrorResponseOauth'
503 403:
504 description: 'action forbidden'
505 content:
506 application/json:
507 schema:
508 $ref: '#/components/schemas/ErrorResponseOauth'
509
510 404:
511 description: 'resource has not been found'
512 content:
513 application/json:
514 schema:
515 $ref: '#/components/schemas/ErrorResponse'
516 500:
517 description: 'Database error'
518 content:
519 application/json:
520 schema:
521 $ref: '#/components/schemas/ErrorResponse'
522 deprecated: false
523
524 /game/join/{gameId}:
525 put:
526 tags:
527 - Game
528 summary: Add new player to game
529 operationId: Addnewplayertogame
530 parameters:
531 - name: Content-Type
532 in: header
533 required: true
534 style: simple
535 schema:
536 type: string
537 example: application/json
538 - name: Authorization
539 in: header
540 required: true
541 style: simple
542 schema:
543 type: string
544 example: Bearer {token}
545 - in: path
546 name: gameId
547 required: true
548 schema:
549 type: string
550 description: Id of the game
551 example: Game ID
552 responses:
553 200:
554 description: 'New player has joined the game'
555 content:
556 application/json:
557 schema:
558 $ref: '#/components/schemas/GameResponseOk'
559
560 401:
561 description: 'Invalid token'
562 content:
563 application/json:
564 schema:
565 $ref: '#/components/schemas/ErrorResponseOauth'
566 403:
567 description: 'action forbidden'
568 content:
569 application/json:
570 schema:
571 $ref: '#/components/schemas/ErrorResponseOauth'
572
573 404:
574 description: 'resource has not been found'
575 content:
576 application/json:
577 schema:
578 $ref: '#/components/schemas/ErrorResponse'
579 500:
580 description: 'Database error'
581 content:
582 application/json:
583 schema:
584 $ref: '#/components/schemas/ErrorResponse'
585 deprecated: false
586
587 /game/{gameId}/location/{locationId}:
588 put:
589 tags:
590 - Game
591 summary: Change game location
592 operationId: Changegamelocation
593 parameters:
594 - name: Content-Type
595 in: header
596 required: true
597 style: simple
598 schema:
599 type: string
600 example: application/json
601 - name: Authorization
602 in: header
603 required: true
604 style: simple
605 schema:
606 type: string
607 example: Bearer {token}
608 - in: path
609 name: gameId
610 required: true
611 schema:
612 type: string
613 description: Id of the game
614 example: Game ID
615 - in: path
616 name: locationId
617 required: true
618 schema:
619 type: string
620 description: Id of the location
621 example: Location ID
622 responses:
623 200:
624 description: 'Game location has changed'
625 content:
626 application/json:
627 schema:
628 $ref: '#/components/schemas/GameResponseOk'
629
630 401:
631 description: 'Invalid token'
632 content:
633 application/json:
634 schema:
635 $ref: '#/components/schemas/ErrorResponseOauth'
636 403:
637 description: 'action forbidden'
638 content:
639 application/json:
640 schema:
641 $ref: '#/components/schemas/ErrorResponseOauth'
642
643 404:
644 description: 'resource has not been found'
645 content:
646 application/json:
647 schema:
648 $ref: '#/components/schemas/ErrorResponse'
649 500:
650 description: 'Database error'
651 content:
652 application/json:
653 schema:
654 $ref: '#/components/schemas/ErrorResponse'
655 deprecated: false
656
657 /game/finish/{gameId}:
658 put:
659 tags:
660 - Game
661 summary: Finish Game
662 operationId: FinishGame
663 parameters:
664 - name: Content-Type
665 in: header
666 required: true
667 style: simple
668 schema:
669 type: string
670 example: application/json
671 - in: path
672 name: gameId
673 required: true
674 schema:
675 type: string
676 description: Id of the game
677 example: Game ID
678 responses:
679 200:
680 description: 'Game location has changed'
681 content:
682 application/json:
683 schema:
684 $ref: '#/components/schemas/ShortResponseOk'
685
686 401:
687 description: 'Invalid token'
688 content:
689 application/json:
690 schema:
691 $ref: '#/components/schemas/ErrorResponseOauth'
692 403:
693 description: 'action forbidden'
694 content:
695 application/json:
696 schema:
697 $ref: '#/components/schemas/ErrorResponseOauth'
698
699 404:
700 description: 'resource has not been found'
701 content:
702 application/json:
703 schema:
704 $ref: '#/components/schemas/ErrorResponse'
705 500:
706 description: 'Database error'
707 content:
708 application/json:
709 schema:
710 $ref: '#/components/schemas/ErrorResponse'
711 deprecated: false
712 /game/5e778462a7b11b0001612e8a:
713 delete:
714 tags:
715 - Game
716 summary: Delete game by ID
717 operationId: DeletegamebyID
718 parameters: []
719 responses:
720 200:
721 description: ''
722 headers: {}
723 deprecated: false
724components:
725 schemas:
726 CreateuserRequest:
727 title: CreateuserRequest
728 required:
729 - username
730 - password
731 - email
732 type: object
733 properties:
734 username:
735 type: string
736 description: 'min length: 5'
737 password:
738 type: string
739 description: 'min length: 8'
740 email:
741 type: string
742 description: 'valid email'
743 example:
744 username: string
745 password: string
746 email: string
747 ChangepasswordRequest:
748 title: ChangepasswordRequest
749 required:
750 - oldPassword
751 - newPassword
752 type: object
753 properties:
754 oldPassword:
755 type: string
756 newPassword:
757 type: string
758 example:
759 oldPassword: adminadmin
760 newPassword: zaq1@WSX
761 CreateLocationRequest:
762 title: CreateLocationRequest
763 required:
764 - name
765 - description
766 - roles
767 type: object
768 properties:
769 name:
770 type: string
771 description:
772 type: string
773 roles:
774 type: array
775 items:
776 $ref: '#/components/schemas/Role'
777 example:
778 name: Jagiellonium Universitetum
779 description: Uniwersytet Jagielloński
780 roles:
781 - name: Arechologia
782 description: XDDDD
783 - name: Prawo
784 description: Crossfit
785 Role:
786 title: Role
787 required:
788 - name
789 - description
790 type: object
791 properties:
792 name:
793 type: string
794 description:
795 type: string
796 example:
797 name: Arechologia
798 description: XDDDD
799 EditlocationRequest:
800 title: EditlocationRequest
801 required:
802 - name
803 - description
804 - roles
805 type: object
806 properties:
807 name:
808 type: string
809 description:
810 type: string
811 roles:
812 type: array
813 items:
814 $ref: '#/components/schemas/Role'
815 example:
816 name: Jagiellonium Universitetum
817 description: Wariaty
818 roles:
819 - name: a
820 description: idiota
821 - name: Prawo
822 description: Edit
823 - name: Prof 3
824 description: idiota3
825 CreateUJlocationRequest:
826 title: CreateUJlocationRequest
827 required:
828 - name
829 - description
830 - roles
831 type: object
832 properties:
833 name:
834 type: string
835 description:
836 type: string
837 roles:
838 type: array
839 items:
840 $ref: '#/components/schemas/Role'
841 example:
842 name: Jagiellonium Universitetum
843 description: Uniwersytet Jagielloński
844 roles:
845 - name: Arechologia
846 description: XDDDD
847 - name: Prawo
848 description: Crossfit
849 CreateotherlocationRequest:
850 title: CreateotherlocationRequest
851 required:
852 - name
853 - description
854 - roles
855 type: object
856 properties:
857 name:
858 type: string
859 description:
860 type: string
861 roles:
862 type: array
863 items:
864 $ref: '#/components/schemas/Role'
865 example:
866 name: Comarch
867 description: McDonald dla Programistow XDD
868 roles:
869 - name: Janusz
870 description: XDDDD
871 - name: Kumarch
872 description: staz
873 - name: Cos
874 description: trzecie
875 CreategameRequest:
876 title: CreategameRequest
877 required:
878 - location
879 type: object
880 properties:
881 location:
882 $ref: '#/components/schemas/Location'
883 example:
884 location:
885 id: 55e778446a7b11b0001612e89
886 Location:
887 title: Location
888 required:
889 - id
890 type: object
891 properties:
892 id:
893 type: string
894 example:
895 id: 55e778446a7b11b0001612e89
896 CreatenewuserRequest:
897 title: CreatenewuserRequest
898 required:
899 - username
900 - password
901 - email
902 type: object
903 properties:
904 username:
905 type: string
906 password:
907 type: string
908 email:
909 type: string
910 example:
911 username: janko123
912 password: janko123
913 email: wadsars@janko.pl
914
915 TokenResponse:
916 title: Access token
917 type: object
918 properties:
919 access_token:
920 type: string
921 token_type:
922 type: string
923 expires_in:
924 type: integer
925 scope:
926 type: string
927 jti:
928 type: string
929
930 CreatedUserResponseOk:
931 title: Created user
932 type: object
933 properties:
934 type:
935 type: string
936 message:
937 type: string
938 user:
939 $ref: '#/components/schemas/UserObject'
940
941
942 UserObject:
943 title: User object
944 type: object
945 properties:
946 id:
947 type: string
948 username:
949 type: string
950 email:
951 type: string
952 authority:
953 type: string
954 enabled:
955 type: boolean
956 signedDate:
957 type: string
958 lastLogged:
959 type: string
960
961 GameResponseOk:
962 title: Created Game
963 type: object
964 properties:
965 type:
966 type: string
967 message:
968 type: string
969 game:
970 $ref: '#/components/schemas/GameObject'
971
972 GameListResponseOk:
973 title: Created Game
974 type: object
975 properties:
976 type:
977 type: string
978 message:
979 type: string
980 existingGames:
981 $ref: '#/components/schemas/ArrayOfGames'
982
983
984 GameObject:
985 title: Game Object
986 type: object
987 properties:
988 id:
989 type: string
990 host:
991 $ref: '#/components/schemas/UserObject'
992 gameTime:
993 type: string
994 location:
995 $ref: '#/components/schemas/LocationObject'
996 playersWithRoles:
997 type: object
998 properties:
999 player:
1000 $ref: '#/components/schemas/RoleObject'
1001
1002 LocationObject:
1003 title: Location Object
1004 type: object
1005 properties:
1006 id:
1007 type: string
1008 name:
1009 type: string
1010 description:
1011 type: string
1012 roles:
1013 $ref: '#/components/schemas/ArrayOfRoles'
1014 date:
1015 type: string
1016
1017
1018 RoleObject:
1019 title: Role Object
1020 type: object
1021 properties:
1022 id:
1023 type: string
1024 name:
1025 type: string
1026 description:
1027 type: string
1028
1029 ArrayOfRoles:
1030 type: array
1031 items:
1032 allOf:
1033 - $ref: '#/components/schemas/RoleObject'
1034
1035 ArrayOfGames:
1036 type: array
1037 items:
1038 allOf:
1039 - $ref: '#/components/schemas/GameObject'
1040
1041 ShortResponseOk:
1042 title: Change ok
1043 type: object
1044 properties:
1045 type:
1046 type: string
1047 message:
1048 type: string
1049
1050 GameInfoOk:
1051 title: info about the game
1052 type: object
1053 properties:
1054 type:
1055 type: string
1056 message:
1057 type: string
1058 playerRole:
1059 $ref: '#/components/schemas/RoleObject'
1060 location:
1061 $ref: '#/components/schemas/LocationObject'
1062 date:
1063 type: string
1064
1065 ErrorResponse:
1066 title: Error response
1067 type: object
1068 properties:
1069 type:
1070 type: string
1071 message:
1072 type: string
1073 description:
1074 type: string
1075 status:
1076 type: string
1077
1078 ErrorResponseOauth:
1079 title: Error oauth response
1080 type: object
1081 properties:
1082 error:
1083 type: string
1084 error_description:
1085 type: string
1086
1087
1088 securitySchemes:
1089 BearerAuth: # arbitrary name for the security scheme
1090 type: http
1091 scheme: bearer
1092 bearerFormat: JWT
1093
1094
1095security:
1096 - BearerAuth: []
1097tags:
1098 - name: User
1099 - name: Location
1100 - name: Game
1101 description: Endpoint requests for game service