Skip to content

Commit bac8525

Browse files
committed
fix(typescript): add name option
1 parent 9cf1a08 commit bac8525

File tree

186 files changed

+3367
-5212
lines changed

Some content is hidden

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

186 files changed

+3367
-5212
lines changed

packages/openapi-ts-tests/test/3.0.x.test.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -256,24 +256,6 @@ describe(`OpenAPI ${version}`, () => {
256256
}),
257257
description: 'exports inline enums (TypeScript)',
258258
},
259-
{
260-
config: createConfig({
261-
input: 'enum-inline.json',
262-
output: 'enum-inline-typescript-namespace',
263-
parser: {
264-
transforms: {
265-
enums: 'root',
266-
},
267-
},
268-
plugins: [
269-
{
270-
enums: 'typescript+namespace',
271-
name: '@hey-api/typescript',
272-
},
273-
],
274-
}),
275-
description: 'exports inline enums (TypeScript namespace)',
276-
},
277259
{
278260
config: createConfig({
279261
input: 'enum-names-values.json',

packages/openapi-ts-tests/test/3.1.x.test.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -270,24 +270,6 @@ describe(`OpenAPI ${version}`, () => {
270270
}),
271271
description: 'exports inline enums (TypeScript)',
272272
},
273-
{
274-
config: createConfig({
275-
input: 'enum-inline.yaml',
276-
output: 'enum-inline-typescript-namespace',
277-
parser: {
278-
transforms: {
279-
enums: 'root',
280-
},
281-
},
282-
plugins: [
283-
{
284-
enums: 'typescript+namespace',
285-
name: '@hey-api/typescript',
286-
},
287-
],
288-
}),
289-
description: 'exports inline enums (TypeScript namespace)',
290-
},
291273
{
292274
config: createConfig({
293275
input: 'enum-names-values.yaml',
Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

3-
export type _110 = '1-10' | '11-20';
4-
53
export const _110 = {
64
110: '1-10',
75
1120: '11-20'
86
} as const;
97

10-
export type MyFoo = 'myFoo' | 'myBar';
8+
export type _110 = typeof _110[keyof typeof _110];
119

1210
export const MyFoo = {
1311
MyFoo: 'myFoo',
1412
MyBar: 'myBar'
1513
} as const;
1614

17-
export type MyFoo2 = 'MyFoo' | 'MyBar';
15+
export type MyFoo = typeof MyFoo[keyof typeof MyFoo];
1816

1917
export const MyFoo2 = {
2018
MyFoo: 'MyFoo',
2119
MyBar: 'MyBar'
2220
} as const;
2321

24-
export type Foo = 'foo' | 'bar' | '' | true | false;
22+
export type MyFoo2 = typeof MyFoo2[keyof typeof MyFoo2];
2523

2624
export const Foo = {
2725
Foo: 'foo',
@@ -31,7 +29,7 @@ export const Foo = {
3129
False: false
3230
} as const;
3331

34-
export type Numbers = 100 | 200 | 300 | -100 | -200 | -300;
32+
export type Foo = typeof Foo[keyof typeof Foo];
3533

3634
export const Numbers = {
3735
100: 100,
@@ -42,20 +40,16 @@ export const Numbers = {
4240
'-300': -300
4341
} as const;
4442

45-
export type Arrays = [
46-
'foo'
47-
] | [
48-
'bar'
49-
] | [
50-
'baz'
51-
];
43+
export type Numbers = typeof Numbers[keyof typeof Numbers];
5244

5345
export const Arrays = {
5446
0: ['foo'],
5547
1: ['bar'],
5648
2: ['baz']
5749
} as const;
5850

51+
export type Arrays = typeof Arrays[keyof typeof Arrays];
52+
5953
export type ClientOptions = {
6054
baseUrl: string;
6155
};
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

3-
export type _110 = '1-10' | '11-20';
4-
53
export const _110 = {
64
'1_10': '1-10',
75
'11_20': '11-20'
86
} as const;
97

10-
export type MyFoo = 'myFoo' | 'myBar';
8+
export type _110 = typeof _110[keyof typeof _110];
119

1210
export const MyFoo = {
1311
MY_FOO: 'myFoo',
1412
MY_BAR: 'myBar'
1513
} as const;
1614

17-
export type MyFoo2 = 'MyFoo' | 'MyBar';
15+
export type MyFoo = typeof MyFoo[keyof typeof MyFoo];
1816

1917
export const MyFoo2 = {
2018
MY_FOO: 'MyFoo',
2119
MY_BAR: 'MyBar'
2220
} as const;
2321

24-
export type Foo = 'foo' | 'bar' | '' | true | false;
22+
export type MyFoo2 = typeof MyFoo2[keyof typeof MyFoo2];
2523

2624
export const Foo = {
2725
FOO: 'foo',
@@ -31,7 +29,7 @@ export const Foo = {
3129
FALSE: false
3230
} as const;
3331

34-
export type Numbers = 100 | 200 | 300 | -100 | -200 | -300;
32+
export type Foo = typeof Foo[keyof typeof Foo];
3533

3634
export const Numbers = {
3735
100: 100,
@@ -42,20 +40,16 @@ export const Numbers = {
4240
'-300': -300
4341
} as const;
4442

45-
export type Arrays = [
46-
'foo'
47-
] | [
48-
'bar'
49-
] | [
50-
'baz'
51-
];
43+
export type Numbers = typeof Numbers[keyof typeof Numbers];
5244

5345
export const Arrays = {
5446
0: ['foo'],
5547
1: ['bar'],
5648
2: ['baz']
5749
} as const;
5850

51+
export type Arrays = typeof Arrays[keyof typeof Arrays];
52+
5953
export type ClientOptions = {
6054
baseUrl: string;
6155
};
Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

3-
export type _110 = '1-10' | '11-20';
4-
53
export const _110 = {
64
110: '1-10',
75
1120: '11-20'
86
} as const;
97

10-
export type MyFoo = 'myFoo' | 'myBar';
8+
export type _110 = typeof _110[keyof typeof _110];
119

1210
export const MyFoo = {
1311
myFoo: 'myFoo',
1412
myBar: 'myBar'
1513
} as const;
1614

17-
export type MyFoo2 = 'MyFoo' | 'MyBar';
15+
export type MyFoo = typeof MyFoo[keyof typeof MyFoo];
1816

1917
export const MyFoo2 = {
2018
myFoo: 'MyFoo',
2119
myBar: 'MyBar'
2220
} as const;
2321

24-
export type Foo = 'foo' | 'bar' | '' | true | false;
22+
export type MyFoo2 = typeof MyFoo2[keyof typeof MyFoo2];
2523

2624
export const Foo = {
2725
foo: 'foo',
@@ -31,7 +29,7 @@ export const Foo = {
3129
false: false
3230
} as const;
3331

34-
export type Numbers = 100 | 200 | 300 | -100 | -200 | -300;
32+
export type Foo = typeof Foo[keyof typeof Foo];
3533

3634
export const Numbers = {
3735
100: 100,
@@ -42,20 +40,16 @@ export const Numbers = {
4240
'-300': -300
4341
} as const;
4442

45-
export type Arrays = [
46-
'foo'
47-
] | [
48-
'bar'
49-
] | [
50-
'baz'
51-
];
43+
export type Numbers = typeof Numbers[keyof typeof Numbers];
5244

5345
export const Arrays = {
5446
0: ['foo'],
5547
1: ['bar'],
5648
2: ['baz']
5749
} as const;
5850

51+
export type Arrays = typeof Arrays[keyof typeof Arrays];
52+
5953
export type ClientOptions = {
6054
baseUrl: string;
6155
};
Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

3-
export type _110 = '1-10' | '11-20';
4-
53
export const _110 = {
64
'1-10': '1-10',
75
'11-20': '11-20'
86
} as const;
97

10-
export type MyFoo = 'myFoo' | 'myBar';
8+
export type _110 = typeof _110[keyof typeof _110];
119

1210
export const MyFoo = {
1311
myFoo: 'myFoo',
1412
myBar: 'myBar'
1513
} as const;
1614

17-
export type MyFoo2 = 'MyFoo' | 'MyBar';
15+
export type MyFoo = typeof MyFoo[keyof typeof MyFoo];
1816

1917
export const MyFoo2 = {
2018
MyFoo: 'MyFoo',
2119
MyBar: 'MyBar'
2220
} as const;
2321

24-
export type Foo = 'foo' | 'bar' | '' | true | false;
22+
export type MyFoo2 = typeof MyFoo2[keyof typeof MyFoo2];
2523

2624
export const Foo = {
2725
foo: 'foo',
@@ -31,7 +29,7 @@ export const Foo = {
3129
false: false
3230
} as const;
3331

34-
export type Numbers = 100 | 200 | 300 | -100 | -200 | -300;
32+
export type Foo = typeof Foo[keyof typeof Foo];
3533

3634
export const Numbers = {
3735
100: 100,
@@ -42,20 +40,16 @@ export const Numbers = {
4240
'-300': -300
4341
} as const;
4442

45-
export type Arrays = [
46-
'foo'
47-
] | [
48-
'bar'
49-
] | [
50-
'baz'
51-
];
43+
export type Numbers = typeof Numbers[keyof typeof Numbers];
5244

5345
export const Arrays = {
5446
0: ['foo'],
5547
1: ['bar'],
5648
2: ['baz']
5749
} as const;
5850

51+
export type Arrays = typeof Arrays[keyof typeof Arrays];
52+
5953
export type ClientOptions = {
6054
baseUrl: string;
6155
};
Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

3-
export type _110 = '1-10' | '11-20';
4-
53
export const _110 = {
64
'1_10': '1-10',
75
'11_20': '11-20'
86
} as const;
97

10-
export type MyFoo = 'myFoo' | 'myBar';
8+
export type _110 = typeof _110[keyof typeof _110];
119

1210
export const MyFoo = {
1311
my_foo: 'myFoo',
1412
my_bar: 'myBar'
1513
} as const;
1614

17-
export type MyFoo2 = 'MyFoo' | 'MyBar';
15+
export type MyFoo = typeof MyFoo[keyof typeof MyFoo];
1816

1917
export const MyFoo2 = {
2018
my_foo: 'MyFoo',
2119
my_bar: 'MyBar'
2220
} as const;
2321

24-
export type Foo = 'foo' | 'bar' | '' | true | false;
22+
export type MyFoo2 = typeof MyFoo2[keyof typeof MyFoo2];
2523

2624
export const Foo = {
2725
foo: 'foo',
@@ -31,7 +29,7 @@ export const Foo = {
3129
false: false
3230
} as const;
3331

34-
export type Numbers = 100 | 200 | 300 | -100 | -200 | -300;
32+
export type Foo = typeof Foo[keyof typeof Foo];
3533

3634
export const Numbers = {
3735
100: 100,
@@ -42,20 +40,16 @@ export const Numbers = {
4240
'-300': -300
4341
} as const;
4442

45-
export type Arrays = [
46-
'foo'
47-
] | [
48-
'bar'
49-
] | [
50-
'baz'
51-
];
43+
export type Numbers = typeof Numbers[keyof typeof Numbers];
5244

5345
export const Arrays = {
5446
0: ['foo'],
5547
1: ['bar'],
5648
2: ['baz']
5749
} as const;
5850

51+
export type Arrays = typeof Arrays[keyof typeof Arrays];
52+
5953
export type ClientOptions = {
6054
baseUrl: string;
6155
};

packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/sdk.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

33
import type { Options as ClientOptions, TDataShape, Client } from './client';
4-
import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen';
4+
import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesErrors, CallWithDuplicateResponsesResponses, CallWithResponsesData, CallWithResponsesErrors, CallWithResponsesResponses, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesErrors, ComplexTypesResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderErrors, CallWithResultFromHeaderResponses, TestErrorCodeData, TestErrorCodeErrors, TestErrorCodeResponses, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyErrors, PostApiVbyApiVersionBodyResponses } from './types.gen';
55
import { client as _heyApiClient } from './client.gen';
66

77
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {

packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/sdk.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

33
import type { Options as ClientOptions, TDataShape, Client } from './client';
4-
import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen';
4+
import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesErrors, CallWithDuplicateResponsesResponses, CallWithResponsesData, CallWithResponsesErrors, CallWithResponsesResponses, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesErrors, ComplexTypesResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderErrors, CallWithResultFromHeaderResponses, TestErrorCodeData, TestErrorCodeErrors, TestErrorCodeResponses, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyErrors, PostApiVbyApiVersionBodyResponses } from './types.gen';
55
import { client as _heyApiClient } from './client.gen';
66

77
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {

0 commit comments

Comments
 (0)