-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathswagger.yaml
1011 lines (988 loc) · 28.3 KB
/
swagger.yaml
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
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
swagger: "2.0"
info:
description: "This is the api-doc for general shit site's backend"
version: "1.0.0"
title: "GS backend"
servers:
- url: "http://localhost:3000/"
description: "development server"
tags:
- name: "Question Admin"
description: ""
- name: "Super User"
description: ""
- name: "User"
description: "Operations about user"
- name: "Question"
description: "Question and testcases endpoint"
- name: "Scoreboard"
description: "scoreboard of all students"
schemes:
# - "https"
- "http"
paths:
/superarea/login:
post:
tags:
- "Super User"
summary: "login with super user informaton"
description: ""
operationId: "addSuper"
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- in: "body"
name: "body"
description: "super user"
required: true
schema:
$ref: "#/definitions/SuperUser"
responses:
"200":
description: "superuser logged successfully"
schema:
type: "object"
example:
admin:
username: "superuser username"
token: "generated token"
"400":
description: "Error while validating"
/superarea/logout:
post:
tags:
- "Super User"
summary: "super user will be logged out"
description: "super user should be authenticated to request for logout"
operationId: "superLogout"
produces:
- "application/json"
parameters:
- name: "Authorization"
in: "header"
description: "needs to be send in bearer thingy"
required: true
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "object"
example:
message: "successfully logged out"
"500":
description: "internal server error"
/questionadmin/:
post:
tags:
- "Question Admin"
summary: "creates new question admin"
operationId: "addQAdmin"
produces:
- "application/json"
parameters:
- name: "body"
in: "body"
required: true
schema:
type: "object"
example:
username: "question admins username"
password: "question admin's password"
- name: "Authorization"
in: "header"
required: true
type: "string"
description: "only superuser can create new admins"
responses:
"201":
description: "successful operation"
schema:
type: "object"
example:
questionAdmin:
_id: "question admin's id"
username : "newAdminUsername"
message: "question admin created successfully"
"400":
description: "error message will be displayed"
get:
tags:
- "Question Admin"
summary: "returns all admins"
operationId: "getAdmins"
produces:
- "application/json"
parameters:
- name: "Authorization"
in: "header"
required: true
type: "string"
responses:
"200":
description: "returns all admins"
schema:
type: "object"
example:
-
_id: "question admin's id"
username : "newAdminUsername"
/questionadmin/{username}:
get:
tags:
- "Question Admin"
summary: "get question admin by username"
description: "Returns a specified question admin"
operationId: "getadminByUsername"
produces:
- "application/json"
parameters:
- name: "username"
in: "path"
description: "username of admin to return"
required: true
type: "string"
- name: "Authorization"
in: "header"
required: true
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "object"
example:
_id: "question admin's id"
username : "newAdminUsername"
"500":
description: "error message will be returned"
# security:
# - api_key: []
patch:
tags:
- "Question Admin"
summary: "Updates a pet in the store with form data"
description: ""
operationId: "updatePetWithForm"
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- name: "body"
in: "body"
description: "updated info of question admin"
required: false
schema:
type: "object"
example:
username: "updated username"
password: "updated password"
- name: "username"
in: "path"
required: true
type: "string"
- name: "Authorization"
in: "header"
required: true
type: "string"
responses:
"200":
description: "returns good message or sth"
schema:
type: "object"
example:
message: "question admin updated successfully"
"500":
description: "error message will be returned"
delete:
tags:
- "Question Admin"
summary: "Deletes a question admin"
description: ""
operationId: "deleteAdmin"
produces:
- "application/json"
parameters:
- name: "username"
in: "path"
required: true
type: "string"
- name: "Authorization"
in: "header"
required: true
type: "string"
responses:
"200":
description: "successfully removed"
schema:
type: "object"
example:
questionAdmin :
_id: "id of question admin"
username: "the username of question admin"
message : "admin successfully deleted"
"500":
description: "error message will be returned"
/questionadmin/login:
post:
tags:
- "Question Admin"
summary: "logs question admin in"
description: ""
operationId: "qadminlogin"
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- name: "body"
in: "body"
description: "info of the question admin"
required: true
schema:
type: "object"
example:
username: "qadmin username"
password: "qadmin password"
responses:
"200":
description: "logged in successfully"
schema:
type: "object"
example :
questionAdmin:
_id: "id of question admin"
username: "admin username"
token: "token"
"400":
description: "error will be returned"
/questionadmin/me/logout:
post:
tags:
- "Question Admin"
summary: "logs out the admin"
description: "Returns a map of status codes to quantities"
operationId: "adminLogout"
produces:
- "application/json"
parameters:
- name: "Authorization"
in: "header"
required: true
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "object"
example:
message: "logged out successfully"
"500":
description: "error will be returned"
/user/:
get:
tags:
- "User"
summary: "gets all users"
description: "This can only be done by superuser."
operationId: "getAllUser"
produces:
- "application/json"
parameters:
- in: "header"
name: "Authorization"
description: "superuser authentication"
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "object"
example:
- studentNumber: "the student number of user"
testcase:
- forQuestion: "the question for"
input: "question inputs"
output: " the question output"
codes:
- forQuestion: "the questionFor"
code: "the path of uploaded code"
"500":
description: "error will be returned"
post:
tags:
- "User"
summary: "Create user"
description: "This can only be done by mr hashemi or superuser."
operationId: "createUser"
produces:
- "application/json"
parameters:
- in: "body"
name: "body"
description: "Created user object"
required: true
schema:
type: "object"
example:
studentNumber: "user student number"
password: "password"
responses:
"201":
description: "successful operation"
schema:
type: "object"
example:
user:
studentNumber: "the student number of user"
testcase:
- forQuestion: "the question for"
input: "question inputs"
output: " the question output"
codes:
- forQuestion: "the questionFor"
code: "the path of uploaded code"
token: "user token"
"500":
description: "error will be returned"
/user/{studentNumber}:
get:
tags:
- "User"
summary: "get the specified user"
description: "this can only be done by superuser (and in future) the user itself"
operationId: "getUserById"
produces:
- "application/json"
parameters:
- in: "path"
name: "studentNumber"
description: "id of the user"
required: true
type: "string"
responses:
default:
description: "returns specified user"
schema:
type: "object"
example:
studentNumber: "the student number of user"
testcase:
- forQuestion: "the question for"
input: "question inputs"
output: " the question output"
codes:
- forQuestion: "the question For"
code: "the path of uploaded code"
"500":
description: "error will be returned"
patch:
tags:
- "User"
summary: "update user"
description: "this can only be done by superuser (and in future) the user itself."
operationId: "updateUser"
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- name: "studentNumber"
in: "path"
description: "id of user which needs to be updated"
required: true
type: "string"
- in: "body"
name: "body"
description: "Updated user object"
required: true
schema:
type: "object"
example:
studentNumber: "updated student number"
password: "updated password"
- in: "header"
name: "Authorization"
description: "superuser auth"
required: true
type: "string"
responses:
default:
description: "updated user"
schema:
type: "object"
example:
user:
studentNumber: "the student number of user"
testcase:
- forQuestion: "the question for"
input: "question inputs"
output: " the question output"
codes:
- forQuestion: "the questionFor"
code: "the path of uploaded code"
message: "user updated successfully"
"500":
description: "error will be displayed "
delete:
tags:
- "User"
summary: "Delete user"
description: "This can only be done by the logged in user or super admin."
operationId: "deleteUser"
produces:
- "application/json"
parameters:
- name: "studentNumber"
in: "path"
description: "The name that needs to be deleted"
required: true
type: "string"
- name: "Authorization"
in: "header"
required: true
type: "string"
responses:
default:
description: "successfully removed and returns removed user"
schema:
type: "object"
example:
removedUser:
studentNumber: "the student number of user"
testcase:
- forQuestion: "the question for"
input: "question inputs"
output: " the question output"
codes:
- forQuestion: "the questionFor"
code: "the path of uploaded code"
message: "user successfully removed"
"500":
description: "error will be returned"
/user/login:
post:
tags:
- "User"
summary: "login into account"
description: "This can be done by anyone."
operationId: "userlogin"
produces:
- "application/json"
parameters:
- in: "body"
name: "body"
description: "request body"
schema:
type: "object"
example:
studentNumber: "user student's number"
password: "user password"
required: true
responses:
"200":
description: "successful operation"
schema:
type: "object"
example:
user:
studentNumber: "the student number of user"
testcase:
-
codes:
-
token: "the generated token"
"400":
description: "error will be returned, propably bad request"
/user/me/logout:
post:
tags:
- "User"
summary: "logout of account"
description: "This can only be done by user itself."
operationId: "userlogout"
produces:
- "application/json"
parameters:
- in: "header"
name: "Authorization"
description: "user auth token"
type: "string"
required: true
responses:
"200":
description: "successful operation"
schema:
type: "object"
example:
message: "logged out successfully"
"400":
description: "error will be returned, propably bad request"
/user/me/changepass:
post:
tags:
- "User"
summary: "change the password of user"
description: "This can only be done by user itself."
operationId: "userChangeOass"
produces:
- "application/json"
parameters:
- in: "header"
name: "Authorization"
description: "user auth token"
type: "string"
required: true
- in : "body"
name : "body"
description: " the body of password"
schema:
type: "object"
example:
newPassword: "the new password of "
required: true
responses:
"200":
description: "successful operation"
schema:
type: "object"
example:
message: "logged out successfully"
"400":
description: "error will be returned, propably bad request"
/user/me/getquestion:
post:
tags:
- "User"
summary: "gets all of avaliable questions"
description: "This can only be done by user itself."
operationId: "userGetQeustion"
produces:
- "application/json"
parameters:
- in: "header"
name: "Authorization"
description: "user auth token"
type: "string"
required: true
responses:
"200":
description: "returns all questions with state attached to it.state can be 'notTouched' or 'finished' or 'workingOn"
schema:
type: "object"
example:
- _id: "the id used in db"
forDate: "the for date"
name: "name of the question"
body: "the body of question"
examples:
- _id: "id of example"
input: "example of input"
output: "example of output"
testGeneratorPath: "the path of testgenerator file"
answerPath: "the path of answer file"
state: "the state of questions ."
"500":
description: "error will be returned"
/question/{id}/testcase/ :
get:
tags:
- "Question"
summary: "gets specified question"
description: "This can only be done by user itself."
operationId: "userGetQeustionById"
produces:
- "application/json"
parameters:
- in: "header"
name: "Authorization"
description: "user auth token"
type: "string"
required: true
- in: "path"
name: "id"
description: "the id of question "
type: "string"
required: true
responses:
"200":
description: "returns all questions with state attached to it.state can be 'notTouched' or 'finished' or 'workingOn"
schema:
type: "object"
example:
- question:
_id: "the id used in db"
forDate: "the for date"
name: "name of the question"
body: "the body of question"
examples:
- _id: "id of example"
input: "example of input"
output: "example of output"
author: "the id of question author"
testGeneratorPath: "the path of testgenerator file"
answerPath: "the path of answer file"
testCase: "string representing testCases"
"500":
description: "error will be returned"
/question/:
post:
tags:
- "Question"
summary: "creates new question"
description: "This can be done only by superuser or question admin. notice content of the request should be FORM-DATA"
operationId: "createQuestion"
consumes:
- "multipart/form-data"
produces:
- "application/json"
parameters:
- name: "date"
in: "formData"
description: "timestamp of the date"
required: true
type: "string"
- name: "name"
in: "formData"
description: "the name of the question"
required: true
type: "string"
- name: "body"
in: "formData"
required: true
description: "the body if question in string"
type: "string"
- name: "examples"
in: "formData"
required: true
description: "an stringified array of object containing inputs and outputs => {input:sth,output:sth}"
type: "string"
- name: "testGenerator"
in: "formData"
required: true
type: "file"
description: "the file of testGenerator . notice it can be only one file"
- name: "answer"
in: "formData"
required: true
type: "file"
description: "the file of answer . notice it can be only one file"
- name: "score"
in: "formData"
required: true
description: "the score of question"
type: "number"
- name: "isWeb"
in: "formData"
required: true
type: "boolean"
- name: "Authorization"
in: "header"
required: true
type: "string"
description: "the bearer auth"
responses:
"201":
description: "successfully creates question and send its object"
schema:
$ref: "#/definitions/Question"
"400":
description: "Bad request .error will be returned"
get:
tags:
- "Question"
description: "this can be done by super user or question admin or user"
summary: "returns all questions"
produces:
- "application/json"
parameters:
- name: "Authorization"
in: "header"
type: "string"
required: true
responses:
"200":
description: "return the list of all questions"
schema:
$ref: "#/definitions/Question"
/question/submit:
post:
tags:
- "Question"
summary : "submits the answer"
description: "can only be done by user"
consumes:
- "multipart/form-data"
produces:
- "application/json"
parameters:
- name: "questionID"
in : "formData"
description: "the id of the question"
type: "string"
required: true
- name: "code"
in: "formData"
type: "file"
description: "submitting code "
required: true
- name: "output"
in: "formData"
type: "file"
description: "text file of output"
required: true
- name: "Authorization"
in: "header"
description: "user auth"
type: "string"
responses:
"200":
description: "returns something good"
schema:
type: "object"
example :
message: "you solved it :)"
"406":
description: "shows that code didn't word"
schema:
type: "object"
example:
message: "output was wrong. try harder"
"500":
description: "sth bad happend, error will be send"
/question/{id}:
get:
tags:
- "Question"
description: "it can be done by user & superuser & question admin"
summary: " returns specified question"
produces:
- "application/json"
parameters:
- in: "path"
name: "id"
required: true
type: "string"
- in: "header"
name: "Authorization"
required: true
type: "string"
responses:
"200":
description: " return question with specified name"
schema:
$ref: "#/definitions/Question"
"500":
description: "error message will be printed"
delete:
tags:
- "Question"
description: "it can only be done by superuser and question admin"
summary: "delete specified question"
produces:
- "application/json"
parameters:
- in: "path"
name: "id"
required: true
type: "string"
- in: "header"
name: "Authorization"
required: true
type: "string"
responses:
"200":
description: "returns removed question and a message"
schema:
example:
removedQuestion:
_id: "the id used in db"
forDate: "the for date"
name: "name of the question"
body: "the body of question"
examples:
- _id: "id of example"
input: "example of input"
output: "example of output"
testGeneratorPath: "the path of testgenerator file"
answerPath: "the path of answer file"
score: "score of question"
message : "successfully removed"
patch:
tags:
- "Question"
summary: "updates specified question"
description: "This can be done only by superuser or question admin. notice content of the request should be FORM-DATA. notice not all of these fields and files should be present"
operationId: "updateQuestion"
consumes:
- "multipart/form-data"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
required: true
type: "string"
description: "id of question in the db"
- name: "forDate"
in: "formData"
description: "the specified date in string"
required: true
type: "string"
- name: "name"
in: "formData"
description: "the name of the question"
required: true
type: "string"
- name: "body"
in: "formData"
required: true
description: "the body if question in string"
type: "string"
- name: "examples"
in: "formData"
required: true
description: "an stringified array of object containing inputs and outputs => {input:sth,output:sth}"
type: "string"
- name: "testGenerator"
in: "formData"
required: true
type: "file"
description: "the file of testGenerator . notice it can be only one file"
- name: "answer"
in: "formData"
required: true
type: "file"
description: "the file of answer . notice it can be only one file"
- name: "Authorization"
in: "header"
required: true
type: "string"
description: "the bearer auth"
responses:
"200":
description: "returns updated question and a message"
schema:
example:
updatedQuestion:
_id: "the id used in db"
forDate: "the for date"
name: "name of the question"
body: "the body of question"
examples:
- _id: "id of example"
input: "example of input"
output: "example of output"
testGeneratorPath: "the path of testgenerator file"
answerPath: "the path of answer file"
score: "score of question"
message : "successfully updated"
"500":
description: "error will be returned"
/scoreboard/ :
get:
tags:
- "Scoreboard"
summary: "getting the scores of all users"
description : "returns all of users rank based on most scores and penalties . everyone can access to this page"
produces:
- "application/json"
responses:
"200":
description: "returns list of info objects"
schema:
example:
newbies:
- studentNumber: "99 ie guys"
penalty: "submittedDate - questionCreated date"
score : "studentScore"
notNoob:
- studentNumber: "non 99 ie guys"
penalty: "submittedDate - questionCreated date"
score : "studentScore"
definitions:
SuperUser:
type: "object"
properties:
username:
type: "string"
password:
type: "string"
tokens:
type: "string"
required:
- username
- password
example:
username: superuser
password: superuserPass
xml:
name: "superuser"
QuestionAdmin:
type: "object"
properties:
username:
type: "integer"
password :
type: "string"
questions:
type: "array"
items:
$ref: "#/definitions/Question"
required:
- username
- password
example:
username: "questionAdminUsername"
password: "qAdminPass"
questions: "[list of questions]"
User:
type: "object"
properties:
studentNumber:
type: "integer"
password:
type: "string"
example:
testCases:
type: "string"
description: "arrays of testcases"
Question:
type: "object"
properties:
_id:
type: "string"
example: "the id of question used in db"
forDate:
type: "string"
example: "for date"
name:
type: "string"
example: "name of the question"
body:
type: "string"
example: "body of the question"
examples:
type: "array"
items:
type: "object"
properties:
input:
type: "string"
example: "example of input"
output:
type: "string"
example: "example of output"