forked from Ptt-official-app/Ptt-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
swagger.yaml
911 lines (890 loc) · 27.8 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
openapi: 3.0.0
info:
title: 'PTT 後端系統協定'
description: '最新版文件請見此處:https://docs.google.com/document/d/18DsZOyrlr5BIl2kKxZH7P2QxFLG02xL2SO0PzVHVY3k/'
version: 0.0.1
servers:
- url: https://pttapp.cc
- url: http://localhost:8080
- url: https://localhost:8080
components:
securitySchemes:
BasicAuth: # <-- arbitrary name for the security scheme
type: http
scheme: basic
BearerAuth:
type: http
scheme: bearer
schemas:
BoardObjectInResponse:
type: object
properties:
type:
type: string
example: 'board'
_bid:
type: string
description: '在BBS內部儲存空間的索引,參考用'
board_id:
type: string
description: '看板ID'
LineObjectInResponse:
type: object
properties:
type:
type: string
example: 'line'
FolderObjectInResponse:
type: object
properties:
type:
type: string
example: 'folder'
title:
type: string
items:
type: array
items:
anyOf:
- $ref: '#/components/schemas/BoardObjectInResponse'
BoardDetailsInResponse:
type: object
properties:
id:
type: string
description: '看板或是分類ID'
type:
type: string
description: '指示為看板或者是分類, board 代表看板,class 代表分類,回傳型別為字串。'
title:
type: string
description: '看板標題'
number_of_user:
type: integer
format: int64
description: '看板使用者數量'
moderators:
description: '版主列表,回傳型別為字串陣列'
type: array
items:
type: string
PushRecord:
type: object
properties:
type:
type: string
id:
type: string
ip_address:
type: string
text:
type: string
time:
type: string
format: date-time
ArticleObjectInResponse:
properties:
filename:
type: string
description: '檔案名稱,Filename ,例如M.1161080752.A.241。'
modified_time:
type: string
format: date-time
description: '修改時間'
recommend_count:
type: integer
format: int64
description: '推文數'
post_date:
type: string
format: date
description: '發文時間,以01/02表示'
title:
type: string
description: '文章標題'
money:
type: integer
description: '文章稿費'
aid:
type: string
description: '文章代碼(AID),例如 #15DA-m91。'
url:
type: string
description: '文章網址'
UserPreferencesObjectInResponse:
properties:
favorite_no_highlight:
type: string
favorite_add_new:
type: string
friend:
type: string
board_sort:
type: string
ad_banner:
type: string
ad_banner_user_song:
type: string
dbcs_aware:
type: string
dbcs_no_interupting_escape:
type: string
dbcs_drop_repeat:
type: string
no_modification_mark:
type: string
colored_modification_mark:
type: string
default_backup:
type: string
new_angel_pager:
type: string
reject_outside_mail:
type: string
secure_login:
type: string
foreign:
type: string
live_right:
type: string
menu_lightbar:
type: string
cursor_ascii:
type: string
pager_ui:
type: string
parameters:
UserIdParam: # <-- Arbitrary name for the definition that will be used to refer to it.
# Not necessarily the same as the parameter name.
name: user_id
in: path
required: true
description: '使用者 id'
schema:
type: string
paths:
/v1/token:
post:
summary: 登入以取得 Access Token 。
security:
- BasicAuth: [ ]
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
username:
type: string
password:
type: string
grant_type:
type: string
enum: ["password"]
required:
- username
- password
- grant_type
responses:
'200':
description: 'ok'
content:
application/json:
schema:
type: object
properties:
access_token:
type: string
example: token
refresh_token:
type: string
example: token
description: "用來更新短效期的 access token,請參考 OAuth 2.0 標準 (RFC 6749)"
expires_in:
type: integer
example: 1612540800
description: "access token 的過期時效,以秒為單位,請參考 OAuth 2.0 標準 (RFC 6749)。"
token_type:
type: string
enum: ["bearer"]
description: "固定為 bearer"
tags:
- 使用者部分
/v1/users/{user_id}/information:
get:
summary: '取得使用者資訊,包括上次上站位置等'
security:
- BearerAuth: [ ]
parameters:
- $ref: '#/components/parameters/UserIdParam'
responses:
'200':
description: 'ok'
content:
application/json:
schema:
type: object
properties:
data:
type: object
properties:
user_id:
type: string
description: '使用者 id'
nickname:
type: string
description: '使用者暱稱'
realname:
type: string
description: '使用者真實姓名,僅本人可見 [需檢討可讀權限]'
number_of_login_days:
type: string
description: '上線日數'
number_of_posts:
type: integer
format: int64
description: '貼文次數'
number_of_badposts:
type: integer
format: int64
description: '劣文次數'
money:
type: integer
format: int64
description: '金錢數量,或稱 P幣數量,僅互加好友可見 [需檢討可讀權限]'
money_description:
type: string
description: '金錢描述,由後端設定的財富等級,以UTF-8中文表示'
last_login_time:
type: string
format: date-time
description: '上次上線時間,以時間方式表示'
last_login_ipv4:
type: string
description: '上次登入IP,原先固定欄位的 IPv4 IP,未來可能被棄置'
last_login_ip:
type: string
description: '上次登入IP,有可能顯示 IPv6 IP 的上線 IP'
last_login_country:
type: string
description: '上次登入國家'
mailbox_description:
type: string
description: '信箱狀態表示文字(延後實作)'
chess_status:
type: object
description: '棋類輸贏狀態表示(延後實作) five: 五子棋 chinese_chess: 中國象棋 conn6: 六子棋 go: 圍棋 dark: 暗棋'
properties:
five:
type: object
properties:
win:
type: integer
format: int64
lose:
type: integer
format: int64
tie:
type: integer
format: int64
plan:
type: object
description: '簽名檔,有可能被稱作計畫檔,原則上可能有16行'
properties:
raw:
type: string
text:
type: string
color_map:
type: string
tags:
- 使用者部分
/v1/users/{user_id}/favorites:
get:
summary: '我的最愛列表'
description: '使用者的我的最愛列表,原則上權限僅供取得使用者本人的最愛資料。解析此資料的成本較高,因此實作上會考慮帶上 Last Modified Header,請在第二次索取相同的資料時附上 。'
security:
- BearerAuth: [ ]
parameters:
- $ref: '#/components/parameters/UserIdParam'
responses:
'200':
description: 'ok'
content:
application/json:
schema:
type: object
properties:
data:
type: object
properties:
items:
type: array
items:
anyOf:
- $ref: '#/components/schemas/BoardObjectInResponse'
- $ref: '#/components/schemas/LineObjectInResponse'
- $ref: '#/components/schemas/FolderObjectInResponse'
tags:
- 使用者部分
post:
summary: '修改我的最愛項目'
description: '新增,刪除,修改我的最愛項目,看板、分隔線或是資料夾'
security:
- BearerAuth: [ ]
parameters:
- $ref: '#/components/parameters/UserIdParam'
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
action:
type: string
enum: [ 'modify_folder_title', 'modify_order', 'delete_favorite', 'add_favorite' ]
position:
type: string
description: '要移動到的位置,如果該位置上已經有東西了,該位置以及後面的東西編號會直接增加,向後移動。如果沒指定或是指定為0會放在該層最後。 例如 2.1.0 會放在第二個項目的第一個項目中的最後面'
type:
type: string
description: '項目類型 board: 看板 line: 分隔線 folder: 資料夾'
board_id:
type: string
title:
type: string
fav_target:
type: string
description: '刪除我的最愛時的目標編號,以 1 開始。 如有資料夾以 . 做分隔,例如 2.1.3 代表第二個項目的第一個項目裡面的第三個項目'
new_title:
type: string
required:
- action
- position
- type
- board_id
- title
- fav_target
- new_title
responses:
'200':
description: 'ok'
content:
application/json:
schema:
type: object
properties:
data:
type: object
properties:
items:
type: array
items:
anyOf:
- $ref: '#/components/schemas/BoardObjectInResponse'
- $ref: '#/components/schemas/LineObjectInResponse'
- $ref: '#/components/schemas/FolderObjectInResponse'
tags:
- 使用者部分
/v1/users/{user_id}/articles:
get:
summary: '該使用者的文章列表'
security:
- BearerAuth: [ ]
parameters:
- $ref: '#/components/parameters/UserIdParam'
responses:
'200':
description: OK
content:
application/json:
schema:
properties:
data:
properties:
items:
type: array
items:
allOf:
- properties:
board_id:
type: string
comment_count:
type: integer
format: int64
description: '留言數'
owner:
type: string
- $ref: '#/components/schemas/ArticleObjectInResponse'
tags:
- 使用者部分
/v1/users/{user_id}/preferences:
get:
summary: '該使用者的偏好設定'
security:
- BearerAuth: [ ]
parameters:
- $ref: '#/components/parameters/UserIdParam'
responses:
'200':
description: OK
content:
application/json:
schema:
properties:
data:
$ref: '#/components/schemas/UserPreferencesObjectInResponse'
tags:
- 使用者部分
/v1/boards:
get:
summary: '取得該使用者所有可見看板以及站長新增看板'
security:
- BearerAuth: [ ]
responses:
'200':
description: 'ok'
content:
application/json:
schema:
type: object
properties:
data:
type: object
properties:
items:
type: array
items:
anyOf:
- $ref: '#/components/schemas/BoardDetailsInResponse'
tags:
- 看板部分
post:
summary: '開新看板'
security:
- BearerAuth: [ ]
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
board_id:
type: string
category:
type: string
title:
type: string
settings:
type: array
items:
type: string
moderators:
type: string
read_settings:
type: array
items:
type: string
required:
- board_id
- category
- title
- settings
- moderators
- read_settings
responses:
'200':
description: 'ok'
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
properties:
id:
type: string
description: 'entry_id'
tags:
- 看板部分
/v1/boards/{board_id}/information:
get:
summary: '取得單個看板資訊'
security:
- BearerAuth: [ ]
parameters:
- name: board_id
in: path
required: true
description: '看板 id'
schema:
type: string
responses:
'200':
description: 'ok'
content:
application/json:
schema:
type: object
properties:
data:
$ref: '#/components/schemas/BoardDetailsInResponse'
tags:
- 看板部分
/v1/classes/{class_id}:
get:
summary: '取得分類看板底下看板列表'
security:
- BearerAuth: [ ]
parameters:
- name: class_id
in: path
required: true
description: '1 為分類看板主目錄'
schema:
type: string
responses:
'200':
description: 'ok'
content:
application/json:
schema:
type: object
properties:
data:
type: object
properties:
items:
type: array
items:
anyOf:
- $ref: '#/components/schemas/BoardDetailsInResponse'
tags:
- 看板部分
/v1/boards/{board_id}/articles:
get:
summary: '取得某看板文章列表'
description: '取得某看板文章列表,同時使用多個條件時,以交集處理。'
security:
- BearerAuth: [ ]
parameters:
- name: board_id
in: path
required: true
description: 'board_id'
schema:
type: string
- name: author
in: query
description: '作者的user id, 字串完全比對'
schema:
type: string
- name: title_contain
in: query
description: '標題'
schema:
type: string
- name: recommend_count_value
in: query
description: '推文數數值'
schema:
type: integer
- name: recommend_count_lt
in: query
description: '推文數數值小於'
schema:
type: integer
- name: recommend_count_le
in: query
description: '推文數數值小於等於'
schema:
type: integer
- name: recommend_count_eq
in: query
description: '推文數數值等於'
schema:
type: integer
- name: recommend_count_gt
in: query
description: '推文數數值大於'
schema:
type: integer
- name: recommend_count_ne
in: query
description: '推文數數值不等於'
schema:
type: integer
- name: recommend_count_ge
in: query
description: '推文數數值大於等於'
schema:
type: integer
responses:
'200':
description: 'ok'
content:
application/json:
schema:
type: object
properties:
data:
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/ArticleObjectInResponse'
tags:
- 文章列表部分
post:
summary: '發表文章'
description: '目前支援輸入標題以及內文,內文部分暫時還沒有支援色碼'
security:
- BearerAuth: [ ]
parameters:
- name: board_id
in: path
required: true
description: 'board_id'
schema:
type: string
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
action:
type: string
enum: ['add_article']
title:
type: string
description: '標題'
article:
type: string
description: '內文'
responses:
'200':
description: 'ok'
content:
application/json:
schema:
type: object
properties:
data:
type: object
properties:
raw:
type: string
description: 'raw_text'
parsed:
type: object
properties:
is_header_modied:
type: string
author_id:
type: string
author_name:
type: string
title:
type: string
post_time:
type: string
format: date-time
board_name:
type: string
text:
type: object
properties:
text:
type: string
color_map:
type: string
signature:
type: object
properties:
text:
type: string
color_map:
type: string
sender_info:
type: object
properties:
site:
type: string
ip_address:
type: string
ip_country:
type: string
edit_records:
type: array
items:
type: string
push_records:
type: array
items:
anyOf:
- $ref: '#/components/schemas/PushRecord'
tags:
- 文章列表部分
/v1/boards/{board_id}/articles/{filename}:
get:
description: ''
parameters:
- name: board_id
in: path
required: true
description: 'board_id'
schema:
type: string
- name: filename
in: path
required: true
description: 'filename'
schema:
type: string
responses:
'200':
description: 'ok'
content:
application/json:
schema:
type: object
properties:
data:
type: object
tags:
- 單篇文章部分
post:
summary: '新增評論推文或是噓文;轉錄文章'
description: ''
security:
- BearerAuth: [ ]
parameters:
- name: board_id
in: path
required: true
description: 'board_id'
schema:
type: string
- name: filename
in: path
required: true
description: 'filename'
schema:
type: string
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
action:
type: string
enum: [ 'append_comment', 'forward_article' ]
type:
type: string
enum: [ '推', '噓', '→' ]
description: '推 or 噓文'
text:
type: string
description: '內文'
email:
type: string
description: '轉錄目標信箱'
board:
type: string
description: '轉錄目標看板'
required:
- action
- type
- text
- email
- board
responses:
'200':
description: 'ok'
content:
application/json:
schema:
type: object
properties:
data:
type: object
properties:
raw:
type: string
parsed:
type: object
properties:
is_header_modify:
type: string
author_id:
type: string
author_name:
type: string
title:
type: string
post_time:
type: string
format: date-time
board_name:
type: string
text:
type: object
properties:
text:
type: string
color_map:
type: string
signature:
type: object
properties:
text:
type: string
color_map:
type: string
sender_info:
type: object
properties:
site:
type: string
ip_address:
type: string
ip_country:
type: string
edit_records:
type: array
items:
type: string
push_records:
type: array
items:
anyOf:
- $ref: '#/components/schemas/PushRecord'
'400':
description: 'permission denied or parameters required'
tags:
- 單篇文章部分
/v1/chat-rooms:
get:
description: ''
responses:
'200':
description: 'ok'
content:
application/json:
schema:
type: object
properties:
data:
type: object
tags:
- 水球部分