Skip to content

Commit 1c1cce9

Browse files
perf: perf parse apifox x-apifox-enum
1 parent 4409620 commit 1c1cce9

File tree

5 files changed

+908
-0
lines changed

5 files changed

+908
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openapi-ts-request': patch
3+
---
4+
5+
perf: perf parse apifox x-apifox-enum

src/generator/serviceGenarator.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
camelCase,
66
entries,
77
filter,
8+
find,
89
forEach,
910
isArray,
1011
isEmpty,
@@ -1097,6 +1098,15 @@ export default class ServiceGenerator {
10971098
enumLabelTypeStr = `{${map(enumArray, (value: string) => {
10981099
const enumLabel = schemaObject['x-apifox']['enumDescriptions'][value];
10991100
1101+
return `${value}:"${enumLabel}"`;
1102+
}).join(',')}}`;
1103+
} else if (schemaObject?.['x-apifox-enum']) {
1104+
enumLabelTypeStr = `{${map(enumArray, (value: string) => {
1105+
const enumLabel = find(
1106+
schemaObject['x-apifox-enum'],
1107+
(item) => item.value === value
1108+
)?.description;
1109+
11001110
return `${value}:"${enumLabel}"`;
11011111
}).join(',')}}`;
11021112
} else {

src/type.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ type ICustomBaseSchemaObject = {
1919
'x-apifox'?: {
2020
enumDescriptions: Record<string, string>;
2121
};
22+
'x-apifox-enum'?: {
23+
value: string;
24+
name: string;
25+
description: string;
26+
}[];
2227
};
2328

2429
export type ArraySchemaObject = Modify<

0 commit comments

Comments
 (0)