forked from engaging-computing/MYR-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
swagger.yaml
962 lines (961 loc) · 23.5 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
swagger: '2.0'
info:
description: |
The API for LearnMYR.org.
version: 1.0.0
title: MYR API - V1
termsOfService: http://learnmyr.org/about/tos
contact:
email: [email protected]
license:
name: MIT
url: https://opensource.org/licenses/MIT
host: learnmyr.org
basePath: /apiv1
schemes:
- https
consumes:
- application/json
produces:
- application/json
tags:
- name: Lessons
description: Lessons API
- name: Courses
description: Courses API
- name: Users
description: Users API
- name: Reference Examples
description: Reference Examples API
- name: Snapshots
description: Snapshots API
- name: Users
description: Authentication API
paths:
/lessons:
get:
tags:
- Lessons
summary: Get all lessons
operationId: getLessons
produces:
- application/json
responses:
200:
description: Array of all lessons
schema:
type: array
items:
$ref: '#/definitions/Lesson'
post:
tags:
- Lessons
summary: Create a new lesson
operationId: createLesson
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: Lesson that needs to be created
required: true
schema:
$ref: '#/definitions/NewLesson'
- in: header
name: x-access-token
type: string
required: true
responses:
201:
description: Lesson created
schema:
$ref: '#/definitions/Lesson'
401:
description: Unauthorized
500:
description: Internal Server Error
/lessons/id/{id}:
get:
tags:
- Lessons
summary: Get a lesson by ID
operationId: getLesson
produces:
- application/json
parameters:
- name: id
in: path
description: ID of the requested lesson
required: true
type: string
responses:
200:
description: Lesson object
schema:
$ref: '#/definitions/Lesson'
put:
tags:
- Lessons
summary: Update a lesson
operationId: updateLesson
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: Lesson properties to update
required: true
schema:
$ref: '#/definitions/NewLesson'
- name: id
in: path
description: ID of the requested lesson to update
required: true
type: string
- in: header
name: x-access-token
type: string
required: true
responses:
200:
description: Lesson updated
schema:
$ref: '#/definitions/Lesson'
401:
description: Unauthorized
500:
description: Internal Server Error
delete:
tags:
- Lessons
summary: Delete a lesson by ID
operationId: deleteLesson
produces:
- application/json
parameters:
- name: id
in: path
description: ID of the lesson to delete
required: true
type: string
- in: header
name: x-access-token
type: string
required: true
responses:
200:
description: Lesson deleted
/courses:
get:
tags:
- Courses
summary: Get all courses
operationId: getCourses
produces:
- application/json
responses:
200:
description: Array of all courses
schema:
type: array
items:
$ref: '#/definitions/Course'
post:
tags:
- Courses
summary: Create a new course
operationId: createCourse
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: Course that needs to be created
required: true
schema:
$ref: '#/definitions/NewCourse'
- in: header
name: x-access-token
type: string
required: true
responses:
201:
description: Course created
schema:
$ref: '#/definitions/Course'
401:
description: Unauthorized
schema:
$ref: '#/definitions/Unauthorized'
409:
description: Duplicate course shortname
schema:
$ref: '#/definitions/Conflict'
500:
description: Internal Server Error
/courses/{name}:
get:
tags:
- Courses
summary: Get a course by its shortname
operationId: getCourseByShortname
produces:
- application/json
parameters:
- name: name
in: path
description: Shortname of the requested course
required: true
type: string
responses:
200:
description: Requested course is returned
schema:
$ref: '#/definitions/Course'
/courses/id/{id}:
get:
tags:
- Courses
summary: Get a course by ID
operationId: getCourseByID
produces:
- application/json
parameters:
- name: id
in: path
description: ID of the requested course
required: true
type: string
responses:
200:
description: Requested course is returned
schema:
$ref: '#/definitions/Course'
put:
tags:
- Courses
summary: Update a lesson
operationId: updateCourse
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: Course properties to update
required: true
schema:
$ref: '#/definitions/NewCourse'
- name: id
in: path
description: ID of the requested course to update
required: true
type: string
- in: header
name: x-access-token
type: string
required: true
responses:
200:
description: Course updated
schema:
$ref: '#/definitions/Course'
401:
description: Unauthorized
schema:
$ref: '#/definitions/Unauthorized'
500:
description: Internal Server Error
delete:
tags:
- Courses
summary: Delete a course by ID
operationId: deleteCourse
produces:
- application/json
parameters:
- name: id
in: path
description: ID of the course to delete
required: true
type: string
- in: header
name: x-access-token
type: string
required: true
responses:
200:
description: Course deleted
401:
description: Unauthorized
schema:
$ref: '#/definitions/Unauthorized'
500:
description: Internal Server Error
/referenceexamples:
get:
tags:
- Reference Examples
summary: Get all reference examples
operationId: getRefEx
produces:
- application/json
responses:
200:
description: Array of all reference examples
schema:
type: array
items:
$ref: '#/definitions/ReferenceExample'
post:
tags:
- Reference Examples
summary: Create a new reference example
operationId: createRefEx
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: Reference example that needs to be created
required: true
schema:
$ref: '#/definitions/NewReferenceExample'
- in: header
name: x-access-token
type: string
required: true
responses:
201:
description: Reference example
schema:
$ref: '#/definitions/ReferenceExample'
401:
description: Unauthorized
schema:
$ref: '#/definitions/Unauthorized'
409:
description: Duplicate function name
schema:
$ref: '#/definitions/Conflict'
500:
description: Internal Server Error
/referenceexamples/{functionName}:
get:
tags:
- Reference Examples
summary: Get a reference example by function name
operationId: getRefExByFuncName
produces:
- application/json
parameters:
- name: functionName
in: path
description: Function name of the requested reference example
required: true
type: string
responses:
200:
description: Requested reference example is returned
schema:
$ref: '#/definitions/ReferenceExample'
/referenceexamples/id/{id}:
get:
tags:
- Reference Examples
summary: Get a reference example by ID
operationId: getRefExByID
produces:
- application/json
parameters:
- name: id
in: path
description: ID of the requested reference example
required: true
type: string
responses:
200:
description: Requested reference example is returned
schema:
$ref: '#/definitions/ReferenceExample'
put:
tags:
- Reference Examples
summary: Update a reference example
operationId: updateRefEx
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: Reference example properties to update
required: true
schema:
$ref: '#/definitions/NewReferenceExample'
- name: id
in: path
description: ID of the requested reference example to update
required: true
type: string
- in: header
name: x-access-token
type: string
required: true
responses:
200:
description: Reference example updated
schema:
$ref: '#/definitions/ReferenceExample'
401:
description: Unauthorized
schema:
$ref: '#/definitions/Unauthorized'
500:
description: Internal Server Error
delete:
tags:
- Reference Examples
summary: Delete a reference example by ID
operationId: deleteRefEx
produces:
- application/json
parameters:
- name: id
in: path
description: ID of the reference example to delete
required: true
type: string
- in: header
name: x-access-token
type: string
required: true
responses:
200:
description: Reference example deleted
401:
description: Unauthorized
schema:
$ref: '#/definitions/Unauthorized'
500:
description: Internal Server Error
/snapshots:
get:
tags:
- Snapshots
summary: Get all snapshots
operationId: getSnapshots
produces:
- application/json
parameters:
- in: header
name: x-access-token
type: string
required: true
responses:
200:
description: Array of all snapshots
schema:
type: array
items:
$ref: '#/definitions/Snapshot'
401:
description: Unauthorized
schema:
$ref: '#/definitions/Unauthorized'
post:
tags:
- Snapshots
summary: Create a new snapshot
operationId: createSnapshot
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: Snapshot that needs to be created
required: true
schema:
$ref: '#/definitions/NewSnapshot'
- in: header
name: x-access-token
type: string
required: true
responses:
201:
description: Snapshot created
schema:
$ref: '#/definitions/Snapshot'
401:
description: Unauthorized
schema:
$ref: '#/definitions/Unauthorized'
500:
description: Internal Server Error
/snapshots/{user}/{timestamp}:
get:
tags:
- Snapshots
summary: Get a snapshot by user ID and timestamp
operationId: getSnapshotByUserTime
produces:
- application/json
parameters:
- name: user
in: path
description: User ID of requested snapshot
required: true
type: string
- name: timestamp
in: path
description: Timestamp of requested snapshot
required: true
type: string
- in: header
name: x-access-token
type: string
required: true
responses:
200:
description: Requested snapshot is returned
schema:
$ref: '#/definitions/Snapshot'
401:
description: Unauthorized
schema:
$ref: '#/definitions/Unauthorized'
/snapshots/id/{id}:
get:
tags:
- Snapshots
summary: Get a snapshot by ID
operationId: getSnapshotByID
produces:
- application/json
parameters:
- name: id
in: path
description: ID of the requested course
required: true
type: string
responses:
200:
description: Requested course is returned
schema:
$ref: '#/definitions/Snapshot'
/users:
get:
tags:
- Users
summary: Get all Users
operationId: getUsers
produces:
- application/json
responses:
200:
description: Array of all Users
schema:
type: array
items:
$ref: '#/definitions/User'
post:
tags:
- Users
summary: Create a new user
operationId: createUser
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: User that needs to be created
required: true
schema:
$ref: '#/definitions/NewUser'
- in: header
name: x-access-token
type: string
required: true
responses:
201:
description: User created
schema:
$ref: '#/definitions/User'
401:
description: Unauthorized
schema:
$ref: '#/definitions/Unauthorized'
409:
description: Duplicate email
schema:
$ref: '#/definitions/Conflict'
500:
description: Internal Server Error
/users/login:
post:
tags:
- Users
summary: Login
operationId: userLogin
produces:
- application/json
responses:
200:
description: User authentication is returned
schema:
$ref: '#/definitions/Auth'
401:
description: Unauthorized
schema:
$ref: '#/definitions/Unauthorized'
/users/logout:
get:
tags:
- Users
summary: Logout
operationId: userLogout
produces:
- application/json
responses:
200:
description: User is logged out
schema:
$ref: '#/definitions/RevokeAuth'
/users/profile:
get:
tags:
- Users
summary: Get the profile of the logged in user
operationId: getUserProfile
produces:
- application/json
responses:
200:
description: User profile is returned
schema:
$ref: '#/definitions/ReferenceExample'
401:
description: Unauthorized
schema:
$ref: '#/definitions/Unauthorized'
/users/id/{id}:
get:
tags:
- Users
summary: Get a user by ID
operationId: getUserByID
produces:
- application/json
parameters:
- name: id
in: path
description: ID of the requested user
required: true
type: string
responses:
200:
description: Requested user is returned
schema:
$ref: '#/definitions/User'
put:
tags:
- Users
summary: Update a user
operationId: updateUser
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: User properties to update
required: true
schema:
$ref: '#/definitions/NewUser'
- name: id
in: path
description: ID of the requested user to update
required: true
type: string
- in: header
name: x-access-token
type: string
required: true
responses:
200:
description: User updated
schema:
$ref: '#/definitions/User'
401:
description: Unauthorized
schema:
$ref: '#/definitions/Unauthorized'
500:
description: Internal Server Error
delete:
tags:
- Users
summary: Delete a user by ID
operationId: deleteUser
produces:
- application/json
parameters:
- name: id
in: path
description: ID of the user to delete
required: true
type: string
- in: header
name: x-access-token
type: string
required: true
responses:
200:
description: User deleted
401:
description: Unauthorized
schema:
$ref: '#/definitions/Unauthorized'
500:
description: Internal Server Error
definitions:
Unauthorized:
type: "string"
example: "Error 401: Not authorized"
Conflict:
type: "object"
properties:
message:
type: string
example: "A course with this function name already exists"
Lesson:
allOf:
- $ref: '#/definitions/NewLesson'
- required:
- _id
- __v
type: object
properties:
_id:
type: string
example: "5c5b173d7682e1058205e316"
__v:
type: integer
example: 1
NewLesson:
type: "object"
required:
- name
- prompt
- code
properties:
name:
type: string
example: "Intro to Geometries"
prompt:
type: string
example: "This lesson will introduce you to using geometries."
code:
type: string
example: "box();"
Course:
allOf:
- $ref: '#/definitions/NewCourse'
- required:
- id
- __v
type: object
properties:
_id:
type: string
example: "5c5b180c7682e1058205e31d"
__v:
type: integer
example: 1
NewCourse:
type: "object"
required:
- name
- shortname
- difficulty
- description
properties:
name:
type: string
example: "Intro to Geometries"
shortname:
type: string
example: "geometries"
description:
type: string
example: "This course will introduce you to using geometries."
difficulty:
type: integer
example: 2
lessons:
type: array
example: ["5c5b173d7682e1058205e316","5c5b17557682e1058205e317"]
Snapshot:
allOf:
- $ref: '#/definitions/NewSnapshot'
- required:
- id
- __v
type: object
properties:
_id:
type: string
example: "5c5b180c7682e1058205e31d"
__v:
type: integer
example: 1
NewSnapshot:
type: "object"
required:
- user
- timestamp
- text
- error
properties:
user:
type: string
example: "c83nf38nf3n09fn303f"
timestamp:
type: string
format: date-time
example: "2018-10-19T04:35:51.196Z"
text:
type: string
example: "box();"
error:
type: boolean
example: true
ReferenceExample:
allOf:
- $ref: '#/definitions/NewReferenceExample'
- required:
- id
- __v
type: object
properties:
_id:
type: string
example: "5c5b180c7682e1058205e31d"
__v:
type: integer
example: 1
NewReferenceExample:
type: "object"
required:
- functionName
- type
- info
- code
properties:
functionName:
type: string
example: "text"
type:
type: string
example: "geometry"
info:
type: string
example: "The text function prints the given text using the current cursor attributes. If given no text, it will print \"Default\". This function returns an elementID."
code:
type: string
example: "text(\"example\");"
functionParams:
type: array
example: ["string"]
suggestedCourse:
type: string
example: "geometry"
User:
allOf:
- $ref: '#/definitions/NewUser'
- required:
- id
- __v
- user_created
- last_login
type: object
properties:
_id:
type: string
example: "5c5b180c7682e1058205e31d"
__v:
type: integer
example: 1
user_created:
type: string
format: date-time
example: "2019-08-04T18:23:14.414Z"
last_login:
type: string
format: date-time
example: "2019-08-04T18:23:14.414Z"
password:
type: string
example: "$2a$10$rcPlmyt0Cy5QWiuXIlZgGeIl5obfjAJPJfFhpj8svZmIqw3dd8UaG"
NewUser:
type: "object"
required:
- email
- password
properties:
name:
type: string
example: "User"
email:
type: string
format: email
example: "[email protected]"
password:
type: string
example: "example_password"
admin:
type: boolean
example: false
subscribed:
type: boolean
example: true
Auth:
type: "object"
required:
- auth
- token
properties:
auth:
type: boolean
example: true
isAdmin:
type: boolean
example: false
token:
type: string
example: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
RevokeAuth:
allOf:
- $ref: '#/definitions/Auth'
properties:
auth:
type: boolean
example: false
token:
type: string
example: null