Skip to content

Commit da4b285

Browse files
committed
refactor: typescript plugin use dsl
1 parent 673db06 commit da4b285

File tree

599 files changed

+19358
-18856
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

599 files changed

+19358
-18856
lines changed

dev/openapi-ts.config.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ export default defineConfig(() => {
4040
// 'circular.yaml',
4141
// 'dutchie.json',
4242
// 'invalid',
43-
// 'full.yaml',
43+
'full.yaml',
44+
// 'object-property-names.yaml',
4445
// 'openai.yaml',
4546
// 'opencode.yaml',
4647
// 'pagination-ref.yaml',
4748
// 'sdk-instance.yaml',
4849
// 'string-with-format.yaml',
49-
'transformers.json',
50+
// 'transformers.json',
5051
// 'type-format.yaml',
5152
// 'validators.yaml',
5253
// 'validators-circular-ref.json',
@@ -225,17 +226,17 @@ export default defineConfig(() => {
225226
{
226227
// case: 'snake_case',
227228
// definitions: '你_snake_{{name}}',
228-
// enums: {
229-
// // case: 'PascalCase',
230-
// // constantsIgnoreNull: true,
231-
// // enabled: false,
232-
// mode: 'javascript',
233-
// },
229+
enums: {
230+
// case: 'PascalCase',
231+
// constantsIgnoreNull: true,
232+
// enabled: false,
233+
// mode: 'typescript',
234+
},
234235
// errors: {
235236
// error: '他們_error_{{name}}',
236237
// name: '你們_errors_{{name}}',
237238
// },
238-
// name: '@hey-api/typescript',
239+
name: '@hey-api/typescript',
239240
// requests: '我們_data_{{name}}',
240241
// responses: {
241242
// name: '我_responses_{{name}}',

examples/openapi-ts-openai/src/client/types.gen.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7373,10 +7373,7 @@ export type ImageGenToolCall = {
73737373
* for `gpt-image-1`. Supports `high` and `low`. Defaults to `low`.
73747374
*
73757375
*/
7376-
export const ImageInputFidelity = {
7377-
HIGH: 'high',
7378-
LOW: 'low',
7379-
} as const;
7376+
export const ImageInputFidelity = { HIGH: 'high', LOW: 'low' } as const;
73807377

73817378
/**
73827379
* Control how much effort the model will exert to match the style and features,
@@ -16101,9 +16098,7 @@ export type TranscriptTextUsageTokens = {
1610116098
*/
1610216099
export type TranscriptionChunkingStrategy = 'auto' | VadConfig;
1610316100

16104-
export const TranscriptionInclude = {
16105-
LOGPROBS: 'logprobs',
16106-
} as const;
16101+
export const TranscriptionInclude = { LOGPROBS: 'logprobs' } as const;
1610716102

1610816103
export type TranscriptionInclude =
1610916104
(typeof TranscriptionInclude)[keyof typeof TranscriptionInclude];

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/sdk.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const postFoo = <ThrowOnError extends boolean = false>(options: Options<P
2323
url: "/foo",
2424
...options,
2525
headers: {
26-
'Content-Type': "text/plain",
26+
"Content-Type": "text/plain",
2727
...options.headers
2828
}
2929
});

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type PostFooData = {
88
body: string;
99
path?: never;
1010
query?: never;
11-
url: '/foo';
11+
url: "/foo";
1212
};
1313

1414
export type PostFooResponses = {

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-PascalCase/types.gen.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,22 @@ export type ClientOptions = {
44
baseUrl: string;
55
};
66

7-
export const _110 = {
8-
110: '1-10',
9-
1120: '11-20'
10-
} as const;
7+
export const _110 = { 110: "1-10", 1120: "11-20" } as const;
118

129
export type _110 = typeof _110[keyof typeof _110];
1310

14-
export const MyFoo = {
15-
MyFoo: 'myFoo',
16-
MyBar: 'myBar'
17-
} as const;
11+
export const MyFoo = { MyFoo: "myFoo", MyBar: "myBar" } as const;
1812

1913
export type MyFoo = typeof MyFoo[keyof typeof MyFoo];
2014

21-
export const MyFoo2 = {
22-
MyFoo: 'MyFoo',
23-
MyBar: 'MyBar'
24-
} as const;
15+
export const MyFoo2 = { MyFoo: "MyFoo", MyBar: "MyBar" } as const;
2516

2617
export type MyFoo2 = typeof MyFoo2[keyof typeof MyFoo2];
2718

2819
export const Foo = {
29-
Foo: 'foo',
30-
Bar: 'bar',
31-
'': '',
20+
Foo: "foo",
21+
Bar: "bar",
22+
"": "",
3223
True: true,
3324
False: false
3425
} as const;
@@ -39,17 +30,17 @@ export const Numbers = {
3930
100: 100,
4031
200: 200,
4132
300: 300,
42-
'-100': -100,
43-
'-200': -200,
44-
'-300': -300
33+
"-100": -100,
34+
"-200": -200,
35+
"-300": -300
4536
} as const;
4637

4738
export type Numbers = typeof Numbers[keyof typeof Numbers];
4839

4940
export const Arrays = {
50-
0: ['foo'],
51-
1: ['bar'],
52-
2: ['baz']
41+
0: ["foo"],
42+
1: ["bar"],
43+
2: ["baz"]
5344
} as const;
5445

5546
export type Arrays = typeof Arrays[keyof typeof Arrays];

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/types.gen.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,22 @@ export type ClientOptions = {
44
baseUrl: string;
55
};
66

7-
export const _110 = {
8-
'1_10': '1-10',
9-
'11_20': '11-20'
10-
} as const;
7+
export const _110 = { "1_10": "1-10", "11_20": "11-20" } as const;
118

129
export type _110 = typeof _110[keyof typeof _110];
1310

14-
export const MyFoo = {
15-
MY_FOO: 'myFoo',
16-
MY_BAR: 'myBar'
17-
} as const;
11+
export const MyFoo = { MY_FOO: "myFoo", MY_BAR: "myBar" } as const;
1812

1913
export type MyFoo = typeof MyFoo[keyof typeof MyFoo];
2014

21-
export const MyFoo2 = {
22-
MY_FOO: 'MyFoo',
23-
MY_BAR: 'MyBar'
24-
} as const;
15+
export const MyFoo2 = { MY_FOO: "MyFoo", MY_BAR: "MyBar" } as const;
2516

2617
export type MyFoo2 = typeof MyFoo2[keyof typeof MyFoo2];
2718

2819
export const Foo = {
29-
FOO: 'foo',
30-
BAR: 'bar',
31-
'': '',
20+
FOO: "foo",
21+
BAR: "bar",
22+
"": "",
3223
TRUE: true,
3324
FALSE: false
3425
} as const;
@@ -39,17 +30,17 @@ export const Numbers = {
3930
100: 100,
4031
200: 200,
4132
300: 300,
42-
'-100': -100,
43-
'-200': -200,
44-
'-300': -300
33+
"-100": -100,
34+
"-200": -200,
35+
"-300": -300
4536
} as const;
4637

4738
export type Numbers = typeof Numbers[keyof typeof Numbers];
4839

4940
export const Arrays = {
50-
0: ['foo'],
51-
1: ['bar'],
52-
2: ['baz']
41+
0: ["foo"],
42+
1: ["bar"],
43+
2: ["baz"]
5344
} as const;
5445

5546
export type Arrays = typeof Arrays[keyof typeof Arrays];

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-camelCase/types.gen.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,22 @@ export type ClientOptions = {
44
baseUrl: string;
55
};
66

7-
export const _110 = {
8-
110: '1-10',
9-
1120: '11-20'
10-
} as const;
7+
export const _110 = { 110: "1-10", 1120: "11-20" } as const;
118

129
export type _110 = typeof _110[keyof typeof _110];
1310

14-
export const MyFoo = {
15-
myFoo: 'myFoo',
16-
myBar: 'myBar'
17-
} as const;
11+
export const MyFoo = { myFoo: "myFoo", myBar: "myBar" } as const;
1812

1913
export type MyFoo = typeof MyFoo[keyof typeof MyFoo];
2014

21-
export const MyFoo2 = {
22-
myFoo: 'MyFoo',
23-
myBar: 'MyBar'
24-
} as const;
15+
export const MyFoo2 = { myFoo: "MyFoo", myBar: "MyBar" } as const;
2516

2617
export type MyFoo2 = typeof MyFoo2[keyof typeof MyFoo2];
2718

2819
export const Foo = {
29-
foo: 'foo',
30-
bar: 'bar',
31-
'': '',
20+
foo: "foo",
21+
bar: "bar",
22+
"": "",
3223
true: true,
3324
false: false
3425
} as const;
@@ -39,17 +30,17 @@ export const Numbers = {
3930
100: 100,
4031
200: 200,
4132
300: 300,
42-
'-100': -100,
43-
'-200': -200,
44-
'-300': -300
33+
"-100": -100,
34+
"-200": -200,
35+
"-300": -300
4536
} as const;
4637

4738
export type Numbers = typeof Numbers[keyof typeof Numbers];
4839

4940
export const Arrays = {
50-
0: ['foo'],
51-
1: ['bar'],
52-
2: ['baz']
41+
0: ["foo"],
42+
1: ["bar"],
43+
2: ["baz"]
5344
} as const;
5445

5546
export type Arrays = typeof Arrays[keyof typeof Arrays];

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-preserve/types.gen.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,22 @@ export type ClientOptions = {
44
baseUrl: string;
55
};
66

7-
export const _110 = {
8-
'1-10': '1-10',
9-
'11-20': '11-20'
10-
} as const;
7+
export const _110 = { "1-10": "1-10", "11-20": "11-20" } as const;
118

129
export type _110 = typeof _110[keyof typeof _110];
1310

14-
export const MyFoo = {
15-
myFoo: 'myFoo',
16-
myBar: 'myBar'
17-
} as const;
11+
export const MyFoo = { myFoo: "myFoo", myBar: "myBar" } as const;
1812

1913
export type MyFoo = typeof MyFoo[keyof typeof MyFoo];
2014

21-
export const MyFoo2 = {
22-
MyFoo: 'MyFoo',
23-
MyBar: 'MyBar'
24-
} as const;
15+
export const MyFoo2 = { MyFoo: "MyFoo", MyBar: "MyBar" } as const;
2516

2617
export type MyFoo2 = typeof MyFoo2[keyof typeof MyFoo2];
2718

2819
export const Foo = {
29-
foo: 'foo',
30-
bar: 'bar',
31-
'': '',
20+
foo: "foo",
21+
bar: "bar",
22+
"": "",
3223
true: true,
3324
false: false
3425
} as const;
@@ -39,17 +30,17 @@ export const Numbers = {
3930
100: 100,
4031
200: 200,
4132
300: 300,
42-
'-100': -100,
43-
'-200': -200,
44-
'-300': -300
33+
"-100": -100,
34+
"-200": -200,
35+
"-300": -300
4536
} as const;
4637

4738
export type Numbers = typeof Numbers[keyof typeof Numbers];
4839

4940
export const Arrays = {
50-
0: ['foo'],
51-
1: ['bar'],
52-
2: ['baz']
41+
0: ["foo"],
42+
1: ["bar"],
43+
2: ["baz"]
5344
} as const;
5445

5546
export type Arrays = typeof Arrays[keyof typeof Arrays];

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-snake_case/types.gen.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,22 @@ export type ClientOptions = {
44
baseUrl: string;
55
};
66

7-
export const _110 = {
8-
'1_10': '1-10',
9-
'11_20': '11-20'
10-
} as const;
7+
export const _110 = { "1_10": "1-10", "11_20": "11-20" } as const;
118

129
export type _110 = typeof _110[keyof typeof _110];
1310

14-
export const MyFoo = {
15-
my_foo: 'myFoo',
16-
my_bar: 'myBar'
17-
} as const;
11+
export const MyFoo = { my_foo: "myFoo", my_bar: "myBar" } as const;
1812

1913
export type MyFoo = typeof MyFoo[keyof typeof MyFoo];
2014

21-
export const MyFoo2 = {
22-
my_foo: 'MyFoo',
23-
my_bar: 'MyBar'
24-
} as const;
15+
export const MyFoo2 = { my_foo: "MyFoo", my_bar: "MyBar" } as const;
2516

2617
export type MyFoo2 = typeof MyFoo2[keyof typeof MyFoo2];
2718

2819
export const Foo = {
29-
foo: 'foo',
30-
bar: 'bar',
31-
'': '',
20+
foo: "foo",
21+
bar: "bar",
22+
"": "",
3223
true: true,
3324
false: false
3425
} as const;
@@ -39,17 +30,17 @@ export const Numbers = {
3930
100: 100,
4031
200: 200,
4132
300: 300,
42-
'-100': -100,
43-
'-200': -200,
44-
'-300': -300
33+
"-100": -100,
34+
"-200": -200,
35+
"-300": -300
4536
} as const;
4637

4738
export type Numbers = typeof Numbers[keyof typeof Numbers];
4839

4940
export const Arrays = {
50-
0: ['foo'],
51-
1: ['bar'],
52-
2: ['baz']
41+
0: ["foo"],
42+
1: ["bar"],
43+
2: ["baz"]
5344
} as const;
5445

5546
export type Arrays = typeof Arrays[keyof typeof Arrays];

0 commit comments

Comments
 (0)