Skip to content

Commit d3f80d7

Browse files
Remove and rename duplicate models in api.yml, change some enum name (bangumi#123)
1 parent ddcb6d5 commit d3f80d7

File tree

7 files changed

+58
-68
lines changed

7 files changed

+58
-68
lines changed

.github/scripts/reset-version-json.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const fs = require("fs");
2+
fs.writeFileSync("open-api/version.json", "{}");

.github/scripts/rewrite-ref-path.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const fs = require('fs');
2+
3+
const apiDoc = fs.readFileSync('open-api/api.yml', {encoding: 'utf-8'});
4+
5+
fs.writeFileSync('open-api/api-gen.yml', apiDoc.replaceAll('v0.yaml#/components/schemas', '#/components/schemas'));
6+

.github/workflows/build.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
key: node-hashFiles('yarn.lock') }}
2323

2424
- run: yarn
25+
- run: node .github/script/rewrite-ref-path.js
2526

2627
- run: node .github/scripts/write-date.js
2728
env:

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.DS_Store
22
.idea
33
node_modules/
4-
public/dist.json
4+
public/dist.json
5+
open-api/api-gen.json
6+
open-api/api-gen.yml

config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"inputFile": "./open-api/version.json"
55
},
66
{
7-
"inputFile": "./open-api/api.yml"
7+
"inputFile": "./open-api/api-gen.yml"
88
},
99
{
1010
"inputFile": "./open-api/v0.yaml"

open-api/api.yml

Lines changed: 41 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ paths:
4848
type: object
4949
properties:
5050
type:
51-
$ref: "#/components/schemas/SubjectType"
51+
$ref: "v0.yaml#/components/schemas/SubjectType"
5252
name:
5353
$ref: "#/components/schemas/SubjectTypeName"
5454
name_cn:
@@ -210,7 +210,7 @@ paths:
210210
tags:
211211
- 搜索
212212
summary: 条目搜索
213-
operationId: getSearchSubjectBykeywords
213+
operationId: searchSubjectByKeywords
214214
parameters:
215215
- name: keywords
216216
in: path
@@ -224,7 +224,7 @@ paths:
224224
description: 条目类型,参考 [SubjectType](#model-SubjectType)
225225
required: false
226226
schema:
227-
$ref: "#/components/schemas/SubjectType"
227+
$ref: "v0.yaml#/components/schemas/SubjectType"
228228
- $ref: "#/components/parameters/responseGroup"
229229
- name: start
230230
in: query
@@ -451,6 +451,21 @@ components:
451451
- 4
452452
- 5
453453
example: 5
454+
x-ms-enum:
455+
name: CollectionStatusId
456+
modelAsString: false
457+
values:
458+
- Wish
459+
- Collect
460+
- Doing
461+
- OnHold
462+
- Dropped
463+
x-enum-varnames:
464+
- Wish
465+
- Collect
466+
- Doing
467+
- OnHold
468+
- Dropped
454469
CollectionStatusType:
455470
description: 收藏状态类型
456471
type: string
@@ -475,24 +490,24 @@ components:
475490
name: CollectionStatusName
476491
modelAsString: false
477492
values:
478-
- Todo
479-
- Done
493+
- Wish
494+
- Collect
480495
- Doing
481-
- Suspended
482-
- Abandoned
496+
- OnHold
497+
- Dropped
483498
x-enum-varnames:
484-
- Todo
485-
- Done
499+
- Wish
500+
- Collect
486501
- Doing
487-
- Suspended
488-
- Abandoned
502+
- OnHold
503+
- Dropped
489504
CollectionStatus:
490505
description: 收藏状态
491-
<br> 1 = wish = 想做
492-
<br> 2 = collect = 做过
493-
<br> 3 = do = 在做
494-
<br> 4 = on_hold = 搁置
495-
<br> 5 = dropped = 抛弃
506+
- 1 = wish = 想做
507+
- 2 = collect = 做过
508+
- 3 = do = 在做
509+
- 4 = on_hold = 搁置
510+
- 5 = dropped = 抛弃
496511
type: object
497512
properties:
498513
id:
@@ -529,14 +544,14 @@ components:
529544
modelAsString: false
530545
values:
531546
- Watched
532-
- Wish
533-
- Abandoned
534-
- Undo
547+
- Queue
548+
- Drop
549+
- Remove
535550
x-enum-varnames:
536551
- Watched
537-
- Wish
538-
- Abandoned
539-
- Undo
552+
- Queue
553+
- Drop
554+
- Remove
540555
ResponseGroup:
541556
description: 返回数据大小
542557
type: string
@@ -553,21 +568,6 @@ components:
553568
x-enum-varnames:
554569
- Small
555570
- Medium
556-
SubjectType:
557-
description: 条目类型
558-
<br> 1 = book
559-
<br> 2 = anime
560-
<br> 3 = music
561-
<br> 4 = game
562-
<br> 6 = real
563-
type: integer
564-
enum:
565-
- 1
566-
- 2
567-
- 3
568-
- 4
569-
- 6
570-
example: 2
571571
SubjectTypeName:
572572
description: 条目类型名称
573573
<br> book
@@ -622,7 +622,7 @@ components:
622622
description: 抛弃
623623
type: integer
624624
example: 86
625-
Subject:
625+
SubjectLegacy:
626626
type: object
627627
properties:
628628
id:
@@ -634,14 +634,14 @@ components:
634634
type: string
635635
example: http://bgm.tv/subject/12
636636
type:
637-
$ref: "#/components/schemas/SubjectType"
637+
$ref: "v0.yaml#/components/schemas/SubjectType"
638638
name:
639639
description: 条目名称
640640
type: string
641641
example: ちょびっツ
642642
SubjectBase:
643643
allOf:
644-
- $ref: "#/components/schemas/Subject"
644+
- $ref: "#/components/schemas/SubjectLegacy"
645645
- type: object
646646
properties:
647647
name_cn:
@@ -782,31 +782,7 @@ components:
782782
type: string
783783
example: Awesome!
784784
usergroup:
785-
$ref: "#/components/schemas/UserGroup"
786-
UserGroup:
787-
description: >-
788-
用户组
789-
<br> 1 = 管理员
790-
<br> 2 = Bangumi 管理猿
791-
<br> 3 = 天窗管理猿
792-
<br> 4 = 禁言用户
793-
<br> 5 = 禁止访问用户
794-
<br> 8 = 人物管理猿
795-
<br> 9 = 维基条目管理猿
796-
<br> 10 = 用户
797-
<br> 11 = 维基人
798-
type: integer
799-
enum:
800-
- 1
801-
- 2
802-
- 3
803-
- 4
804-
- 5
805-
- 8
806-
- 9
807-
- 10
808-
- 11
809-
example: 11
785+
$ref: "v0.yaml#/components/schemas/UserGroup"
810786
StatusCode:
811787
description: 响应状态(HTTP 状态码都为 200)
812788
type: object

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
22
"scripts": {
3+
"fillVersion": "node .github/scripts/write-date.js",
4+
"resetVersion": "node .github/scripts/reset-version-json.js",
5+
"resolveRef": "node .github/scripts/rewrite-ref-path.js",
36
"build": "openapi-merge-cli --config config.json",
4-
"build:local": "node .github/scripts/write-date.js && npm run build"
7+
"build:local": "npm run resolveRef && npm run fillVersion && npm run build && npm run resetVersion"
58
},
69
"dependencies": {
710
"js-yaml": "^4.1.0",

0 commit comments

Comments
 (0)