Skip to content

Commit b45b066

Browse files
committed
fix: number enum properties to avoid collision
1 parent e57fdde commit b45b066

13 files changed

Lines changed: 64 additions & 20 deletions

File tree

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-javascript/types.gen.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ export type Foo = {
88
type?: TypeEnum;
99
};
1010

11-
export const TypeEnum = { FOO: 'foo', BAR: 'bar' } as const;
11+
export const TypeEnum = {
12+
FOO: 'foo',
13+
BAR: 'bar',
14+
FOO_BAR: 'FooBar',
15+
FOO_BAR2: 'fooBar',
16+
FOO_BAR3: 'foo bar'
17+
} as const;
1218

1319
export type TypeEnum = typeof TypeEnum[keyof typeof TypeEnum];

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-typescript/types.gen.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@ export type Foo = {
1010

1111
export enum TypeEnum {
1212
FOO = 'foo',
13-
BAR = 'bar'
13+
BAR = 'bar',
14+
FOO_BAR = 'FooBar',
15+
FOO_BAR2 = 'fooBar',
16+
FOO_BAR3 = 'foo bar'
1417
}

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export type Foo = {
88
type?: TypeEnum;
99
};
1010

11-
export type TypeEnum = 'foo' | 'bar';
11+
export type TypeEnum = 'foo' | 'bar' | 'FooBar' | 'fooBar' | 'foo bar';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

3-
export { type Bar, Baz, type ClientOptions, type Foo, FooEnum, FooEnum2, type GetFooData, type GetFooResponse, type GetFooResponses, type PostFooData, type PostFooResponse, type PostFooResponses, type PutFooData, type PutFooResponse, type PutFooResponses } from './types.gen';
3+
export { type Bar, Baz, type ClientOptions, type Foo, FooEnum, FooEnum2, type GetFooData, type GetFooResponse, type GetFooResponses, type PostFooData, type PostFooResponse, type PostFooResponses, type PutFooData, type PutFooResponse, type PutFooResponses, TypeEnum } from './types.gen';

packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-javascript/types.gen.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export type ClientOptions = {
55
};
66

77
export type Foo = {
8-
type?: FooEnum;
8+
type?: TypeEnum;
99
};
1010

1111
export type Bar = {
@@ -16,14 +16,24 @@ export const Baz = { QUX: 'qux', QUUX: 'quux' } as const;
1616

1717
export type Baz = typeof Baz[keyof typeof Baz];
1818

19-
export const FooEnum = { FOO: 'foo', BAR: 'bar' } as const;
19+
export const FooEnum = {
20+
FOO: 'foo',
21+
BAR: 'bar',
22+
FOO_BAR: 'FooBar',
23+
FOO_BAR2: 'fooBar',
24+
FOO_BAR3: 'foo bar'
25+
} as const;
2026

2127
export type FooEnum = typeof FooEnum[keyof typeof FooEnum];
2228

2329
export const FooEnum2 = { BAZ: 'baz' } as const;
2430

2531
export type FooEnum2 = typeof FooEnum2[keyof typeof FooEnum2];
2632

33+
export const TypeEnum = { FOO: 'foo', BAR: 'bar' } as const;
34+
35+
export type TypeEnum = typeof TypeEnum[keyof typeof TypeEnum];
36+
2737
export type GetFooData = {
2838
body?: never;
2939
path?: never;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

3-
export { type Bar, Baz, type ClientOptions, type Foo, FooEnum, FooEnum2, type GetFooData, type GetFooResponse, type GetFooResponses, type PostFooData, type PostFooResponse, type PostFooResponses, type PutFooData, type PutFooResponse, type PutFooResponses } from './types.gen';
3+
export { type Bar, Baz, type ClientOptions, type Foo, FooEnum, FooEnum2, type GetFooData, type GetFooResponse, type GetFooResponses, type PostFooData, type PostFooResponse, type PostFooResponses, type PutFooData, type PutFooResponse, type PutFooResponses, TypeEnum } from './types.gen';

packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-typescript/types.gen.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export type ClientOptions = {
55
};
66

77
export type Foo = {
8-
type?: FooEnum;
8+
type?: TypeEnum;
99
};
1010

1111
export type Bar = {
@@ -19,13 +19,21 @@ export enum Baz {
1919

2020
export enum FooEnum {
2121
FOO = 'foo',
22-
BAR = 'bar'
22+
BAR = 'bar',
23+
FOO_BAR = 'FooBar',
24+
FOO_BAR2 = 'fooBar',
25+
FOO_BAR3 = 'foo bar'
2326
}
2427

2528
export enum FooEnum2 {
2629
BAZ = 'baz'
2730
}
2831

32+
export enum TypeEnum {
33+
FOO = 'foo',
34+
BAR = 'bar'
35+
}
36+
2937
export type GetFooData = {
3038
body?: never;
3139
path?: never;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

3-
export type { Bar, Baz, ClientOptions, Foo, FooEnum, FooEnum2, GetFooData, GetFooResponse, GetFooResponses, PostFooData, PostFooResponse, PostFooResponses, PutFooData, PutFooResponse, PutFooResponses } from './types.gen';
3+
export type { Bar, Baz, ClientOptions, Foo, FooEnum, FooEnum2, GetFooData, GetFooResponse, GetFooResponses, PostFooData, PostFooResponse, PostFooResponses, PutFooData, PutFooResponse, PutFooResponses, TypeEnum } from './types.gen';

packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline/types.gen.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export type ClientOptions = {
55
};
66

77
export type Foo = {
8-
type?: FooEnum;
8+
type?: TypeEnum;
99
};
1010

1111
export type Bar = {
@@ -14,10 +14,12 @@ export type Bar = {
1414

1515
export type Baz = 'qux' | 'quux';
1616

17-
export type FooEnum = 'foo' | 'bar';
17+
export type FooEnum = 'foo' | 'bar' | 'FooBar' | 'fooBar' | 'foo bar';
1818

1919
export type FooEnum2 = 'baz';
2020

21+
export type TypeEnum = 'foo' | 'bar';
22+
2123
export type GetFooData = {
2224
body?: never;
2325
path?: never;
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
describe('internal entry index', () => {
2-
it('should be exported', async () => {
3-
const internal = await import('../internal');
4-
expect(internal.getSpec).toBeDefined();
5-
expect(internal.initConfigs).toBeDefined();
6-
expect(internal.parseOpenApiSpec).toBeDefined();
7-
});
2+
it(
3+
'should be exported',
4+
async () => {
5+
const internal = await import('../internal');
6+
expect(internal.getSpec).toBeDefined();
7+
expect(internal.initConfigs).toBeDefined();
8+
expect(internal.parseOpenApiSpec).toBeDefined();
9+
},
10+
{ timeout: 10000 },
11+
);
812
});

0 commit comments

Comments
 (0)