-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec.yaml
2102 lines (2001 loc) · 70.8 KB
/
spec.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
openapi: 3.0.0
servers:
# Added by API Auto Mocking Plugin
- description: SwaggerHub API Auto Mocking
url: https://virtserver.swaggerhub.com/JacobLinCool/UniCourse/1.0.0
info:
description: UniCourse API
version: "1.0.0"
title: UniCourse API
contact:
email: [email protected]
tags:
- name: auth
description: Auth API
- name: account
description: Account API
- name: profile
description: Profile API
- name: course
description: Course API
- name: forum
description: Forum API
security:
- bearer: []
paths:
/auth/login:
post:
tags:
- auth
security: []
summary: 登入
operationId: AuthLogin
description: |
登入
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/LoginPayload"
responses:
"200":
description: Always 200
content:
application/json:
schema:
$ref: "#/components/schemas/AuthResponse"
/auth/register:
post:
tags:
- auth
security: []
summary: 註冊
operationId: AuthRegister
description: |
註冊
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/RegisterPayload"
responses:
"200":
description: Always 200
content:
application/json:
schema:
$ref: "#/components/schemas/AuthResponse"
/auth/reset:
post:
tags:
- auth
security: []
summary: 發送重設密碼驗證信
operationId: AuthReset
description: |
發送重設密碼驗證信
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ResetPayload"
responses:
"200":
description: Always 200
content:
application/json:
schema:
$ref: "#/components/schemas/ResetResponse"
/auth/reset_verify:
post:
tags:
- auth
security: []
summary: 重設密碼
operationId: AuthResetVerify
description: |
重設密碼
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ResetVerifyPayload"
responses:
"200":
description: Always 200
content:
application/json:
schema:
$ref: "#/components/schemas/ResetVerifyResponse"
/me:
get:
tags:
- account
summary: 自己的資料
operationId: AccountRead
description: |
自己的資料
responses:
"200":
description: Always 200
content:
application/json:
schema:
$ref: "#/components/schemas/MeResponse"
patch:
tags:
- account
summary: 更新自己的資料
operationId: AccountUpdate
description: |
更新自己的資料
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/MePatch"
responses:
"200":
description: Always 200
content:
application/json:
schema:
$ref: "#/components/schemas/MeResponse"
/profile/{username}:
get:
tags:
- profile
summary: 取得使用者公開資料
operationId: ProfileRead
description: |
取得使用者公開資料
parameters:
- in: path
name: username
description: 使用者 Username
required: true
schema:
type: string
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/ProfileResponse"
/courses:
get:
tags:
- course
summary: 搜尋符合條件的課程 Metae
operationId: CourseMetaRead
description: |
搜尋符合條件的課程 Metae
parameters:
- in: query
name: q
description: >-
以空白分割多個 filter,進行 AND 查詢(OR 查詢可視情況由後端擴充)
每個 filter 的形式為 `key:value`,或者,也可以沒有 `key` 只有 `value`
做模糊搜尋(或預設搜尋標題跟科目代碼之類的?)
例如:
`程式設計 department:資工系 teacher:紀` 代表要搜尋任何包含「程式設計」且教師有「紀」的「資工系」課程
建議 filters,這部分是後端可自行決定:
- department (d) 系所 `d:資工`
- teacher (T) 教師 `T:紀`
- title (t) 課程名稱 `t:程式設計`
- code (c) 科目代碼 `c:CSU0002`
- serial (s) 開課序號 `s:2949`
- year (y) 開課學年度 `y:110`(或者要合併學期 `110-2` 或 `1102`)
- term (tm) 開課學期 `tm:2`
- tag (tg) 標籤 `tg:UX`
- program (p) 學分學程 `p:音樂科技`
- general (g) 通識領域 `g:人文`
- rating (r) 綜合評分 `r:>4.5` (`>` `<` `=`)
- usefulness (uf) 實用性 `u:>4`
- sweetness (sw) 甜度 `s:>4`
- easiness (es) 涼度 `e:>4`
- day (d) 週幾授課 `d:1` (考慮與節數時段合併?)
- session (sn) 包含的節數時段 `sn:1-2` `sn:5`
- location (l) 地點 `l:公館`
- quota (q) 名額 `q:>10`
- grading (gd) 評分方法 `gd:作業>49`
- hours (h) 實際每週授課時數 `h:<3`
- methodology (m) 教學方法包含 `m:講述法`
- prerequisite (pr) 先修課程 `pr:程式設計(一)`
required: true
schema:
$ref: "#/components/schemas/ComplexCourseSearchString"
- in: query
name: limit
description: Metae 上限
schema:
type: number
default: 100
- in: query
name: offset
description: 偏移量
schema:
type: number
minimum: 0
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/CourseMetaResponse"
/courses/{key}:
get:
tags:
- course
summary: 取得課程資料
operationId: CourseInfoRead
description: |
取得課程資料
parameters:
- in: path
name: key
description: 課程定位鍵 year-term-serial
required: true
schema:
type: string
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/CourseInfoResponse"
/courses/{key}/vote:
put:
tags:
- course
summary: 課程評分
operationId: CourseVote
description: |
課程評分
parameters:
- in: path
name: key
description: 課程定位鍵 year-term-serial
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CourseRating"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Response"
/courses/tags:
get:
tags:
- course
summary: 搜尋 Course Tags
operationId: CourseTagsRead
description: |
搜尋 Course Tags
parameters:
- in: query
name: q
description: 搜尋字串
required: true
schema:
type: string
- in: query
name: limit
description: 上限
schema:
type: number
default: 5
- in: query
name: offset
description: 偏移量
schema:
type: number
minimum: 0
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/CourseTagsResponse"
/posts/latest:
get:
tags:
- forum
summary: 取得最新貼文
operationId: ForumPostsLatest
description: |
取得最新貼文
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/PostsResponse"
/posts:
get:
tags:
- forum
summary: 搜尋貼文
operationId: ForumPostsSearch
description: |
搜尋貼文
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/PostsResponse"
parameters:
- in: query
name: q
description: >-
以空白分割多個 filter,進行 AND 查詢(OR 查詢可視情況由後端擴充)
每個 filter 的形式為 `key:value`,或者,也可以沒有 `key` 只有 `value`
做模糊搜尋(或預設搜尋標題跟科目代碼之類的?)
例如:
`考古題 date:>2021` 代表要搜尋任何包含「考古題」且在 2021 年之後的貼文
建議 filters,這部分是後端可自行決定:
- title (t) 貼文標題 `t:考古題`
- code (c) 相關課程科目代碼 `c:CSU0002`
- tag (tg) 標籤 `tg:考古題`
- program (p) 學分學程 `p:音樂科技`
- date (d) 發文時間 `d:>2021`
- vote (v) 正向投票數 `v:>100`
- author (a) 發文者 `a:user123`
required: true
schema:
$ref: "#/components/schemas/ComplexPostSearchString"
- in: query
name: limit
description: 回傳數量
schema:
type: number
default: 20
- in: query
name: offset
description: 偏移量
schema:
type: number
minimum: 0
post:
tags:
- forum
summary: 新增貼文
operationId: ForumPostCreate
description: |
新增貼文
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/PostPayload"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/PostSuccessResponse"
/posts/tags:
get:
tags:
- forum
summary: 搜尋 Post Tags
operationId: PostTagsRead
description: |
搜尋 Post Tags
parameters:
- in: query
name: q
description: 搜尋字串
required: true
schema:
type: string
- in: query
name: limit
description: 上限
schema:
type: number
default: 5
- in: query
name: offset
description: 偏移量
schema:
type: number
minimum: 0
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/CourseTagsResponse"
/posts/{post_id}:
get:
tags:
- forum
summary: 取得貼文
operationId: ForumPostRead
description: |
取得貼文
parameters:
- in: path
name: post_id
description: 貼文 ID
required: true
schema:
type: string
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/PostResponse"
put:
tags:
- forum
summary: 編輯貼文
operationId: ForumPostUpdate
description: |
編輯貼文
parameters:
- in: path
name: post_id
description: 貼文 ID
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/PostPayload"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/PostSuccessResponse"
/posts/{post_id}/comments:
get:
tags:
- forum
summary: 取得貼文留言
operationId: ForumCommentsRead
description: |
取得貼文留言
parameters:
- in: path
name: post_id
description: 貼文 ID
required: true
schema:
type: string
- in: query
name: limit
description: 留言篇數
schema:
type: number
default: 10
- in: query
name: offset
description: 偏移量
schema:
type: number
minimum: 0
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/CommentsResponse"
/posts/{post_id}/vote:
put:
tags:
- forum
summary: 貼文評分投票
operationId: PostVote
description: |
貼文評分投票
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Response"
parameters:
- in: path
name: post_id
description: 貼文 ID
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
properties:
type:
type: number
description: "0: 取消 +: upvote -: downvote"
/comments/{comment_id}:
put:
tags:
- forum
summary: 編輯留言
operationId: ForumCommentUpdate
description: |
編輯留言
parameters:
- in: path
name: comment_id
description: 留言 ID
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CommentPayload"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/CommentSuccessResponse"
/comments:
post:
tags:
- forum
summary: 新增留言
operationId: ForumCommentCreate
description: |
新增留言
parameters:
- in: query
name: post
description: 貼文 ID
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CommentPayload"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/CommentSuccessResponse"
/comments/{comment_id}/vote:
put:
tags:
- forum
summary: 留言評分投票
operationId: CommentVote
description: |
留言評分投票
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Response"
parameters:
- in: path
name: comment_id
description: 貼文 ID
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
properties:
type:
type: number
description: "0: 取消 +: upvote -: downvote"
components:
securitySchemes:
bearer:
type: http
scheme: bearer
bearerFormat: JWT
schemas:
Response:
properties:
success:
title: Response.success
description: 操作成功?
type: boolean
data:
title: Response.data
description: 資料,如果有
type: object
err:
properties:
title:
title: Response.err.title
type: string
message:
title: Response.err.message
type: string
required:
- title
- message
additionalProperties: false
title: Response.err
description: 失敗,錯誤資訊
type: object
token:
title: Response.token
description: 如果該操作會影響使用者包含在 JWT 內的狀態,則需核發新的 JWT,或用於續簽
type: string
required:
- success
additionalProperties: false
title: Response
description: API Response
type: object
Badge:
properties:
name:
title: Badge.name
type: string
image:
title: Badge.image
type: string
required:
- name
- image
additionalProperties: false
title: Badge
type: object
Permission:
properties:
name:
title: Permission.name
type: string
required:
- name
additionalProperties: false
title: Permission
type: object
JWTPayload:
properties:
user:
properties:
id:
title: JWTPayload.user.id
description: 使用者 ID
type: number
username:
$ref: "#/components/schemas/Username"
title: JWTPayload.user.username
description: 使用者 Username
email:
title: JWTPayload.user.email
description: 使用者 Email
type: string
display:
title: JWTPayload.user.display
description: 使用者顯示名稱
type: string
exp:
title: JWTPayload.user.exp
description: 使用者經驗值
type: number
perms:
items:
title: JWTPayload.user.perms.[]
type: string
title: JWTPayload.user.perms
description: 使用者特殊權限 @example `["admin", "moderator"]`
type: array
verified:
title: JWTPayload.user.verified
description: 是否通過學校驗證
type: boolean
required:
- id
- username
- email
- display
- exp
- perms
- verified
additionalProperties: false
title: JWTPayload.user
type: object
exp:
title: JWTPayload.exp
description: JWT 過期時戳
type: number
iat:
title: JWTPayload.iat
description: JWT 簽發時戳
type: number
id:
title: JWTPayload.id
description: JWT ID,隨機字串
type: string
required:
- user
- exp
- iat
- id
additionalProperties: false
title: JWTPayload
type: object
LoginPayload:
properties:
username:
title: LoginPayload.username
description: 使用者 Username
type: string
password:
title: LoginPayload.password
description: 使用者密碼
type: string
recaptcha:
title: LoginPayload.recaptcha
description: reCAPTCHA 的那個 code
type: string
required:
- username
- password
- recaptcha
additionalProperties: false
title: LoginPayload
type: object
RegisterPayload:
properties:
username:
title: RegisterPayload.username
description: 使用者 Username
type: string
password:
title: RegisterPayload.password
description: 使用者密碼
type: string
email:
title: RegisterPayload.email
description: 使用者電子郵件
type: string
recaptcha:
title: RegisterPayload.recaptcha
description: reCAPTCHA 的那個 code
type: string
required:
- username
- password
- email
- recaptcha
additionalProperties: false
title: RegisterPayload
type: object
AuthResponse:
allOf:
- $ref: "#/components/schemas/Response"
additionalProperties: false
title: AuthResponse
type: object
ResetPayload:
properties:
email:
title: ResetPayload.email
description: 使用者電子郵件
type: string
recaptcha:
title: ResetPayload.recaptcha
description: reCAPTCHA 的那個 code
type: string
required:
- email
- recaptcha
additionalProperties: false
title: ResetPayload
type: object
ResetResponse:
allOf:
- $ref: "#/components/schemas/Response"
properties:
data:
properties:
email:
title: ResetResponse.data.email
description: 已寄送的電子郵件
type: string
required:
- email
additionalProperties: false
title: ResetResponse.data
description: 成功
type: object
additionalProperties: false
title: ResetResponse
type: object
ResetVerifyPayload:
properties:
code:
title: ResetVerifyPayload.code
description: 驗證碼
type: string
password:
title: ResetVerifyPayload.password
description: 新密碼
type: string
recaptcha:
title: ResetVerifyPayload.recaptcha
description: reCAPTCHA 的那個 code
type: string
required:
- code
- password
- recaptcha
additionalProperties: false
title: ResetVerifyPayload
type: object
ResetVerifyResponse:
allOf:
- $ref: "#/components/schemas/Response"
properties:
data:
properties:
name:
title: ResetVerifyResponse.data.name
description: 密碼被更新者名稱
type: string
required:
- name
additionalProperties: false
title: ResetVerifyResponse.data
description: 成功
type: object
additionalProperties: false
title: ResetVerifyResponse
type: object
Comment:
properties:
id:
title: Comment.id
type: number
user:
$ref: "#/components/schemas/Username"
title: Comment.user
content:
title: Comment.content
type: string
time:
title: Comment.time
type: string
format: date-time
vote:
properties:
up:
title: Comment.vote.up
type: number
down:
title: Comment.vote.down
type: number
required:
- up
- down
additionalProperties: false
title: Comment.vote
type: object
selected:
title: Comment.selected
description: 最佳解
type: boolean
required:
- id
- user
- content
- time
- vote
additionalProperties: false
title: Comment
description: 當跟隨的 Post 是 course 時,視為一般留言,當 Post 是 question 時,視為回答
type: object
CommentResponse:
allOf:
- $ref: "#/components/schemas/Response"
properties: