fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: number enum properties to avoid collision

+64 -20
+7 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-javascript/types.gen.ts
··· 8 8 type?: TypeEnum; 9 9 }; 10 10 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; 12 18 13 19 export type TypeEnum = typeof TypeEnum[keyof typeof TypeEnum];
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-typescript/types.gen.ts
··· 10 10 11 11 export enum TypeEnum { 12 12 FOO = 'foo', 13 - BAR = 'bar' 13 + BAR = 'bar', 14 + FOO_BAR = 'FooBar', 15 + FOO_BAR2 = 'fooBar', 16 + FOO_BAR3 = 'foo bar' 14 17 }
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline/types.gen.ts
··· 8 8 type?: TypeEnum; 9 9 }; 10 10 11 - export type TypeEnum = 'foo' | 'bar'; 11 + export type TypeEnum = 'foo' | 'bar' | 'FooBar' | 'fooBar' | 'foo bar';
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-javascript/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 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';
+12 -2
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-javascript/types.gen.ts
··· 5 5 }; 6 6 7 7 export type Foo = { 8 - type?: FooEnum; 8 + type?: TypeEnum; 9 9 }; 10 10 11 11 export type Bar = { ··· 16 16 17 17 export type Baz = typeof Baz[keyof typeof Baz]; 18 18 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; 20 26 21 27 export type FooEnum = typeof FooEnum[keyof typeof FooEnum]; 22 28 23 29 export const FooEnum2 = { BAZ: 'baz' } as const; 24 30 25 31 export type FooEnum2 = typeof FooEnum2[keyof typeof FooEnum2]; 32 + 33 + export const TypeEnum = { FOO: 'foo', BAR: 'bar' } as const; 34 + 35 + export type TypeEnum = typeof TypeEnum[keyof typeof TypeEnum]; 26 36 27 37 export type GetFooData = { 28 38 body?: never;
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-typescript/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 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';
+10 -2
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-typescript/types.gen.ts
··· 5 5 }; 6 6 7 7 export type Foo = { 8 - type?: FooEnum; 8 + type?: TypeEnum; 9 9 }; 10 10 11 11 export type Bar = { ··· 19 19 20 20 export enum FooEnum { 21 21 FOO = 'foo', 22 - BAR = 'bar' 22 + BAR = 'bar', 23 + FOO_BAR = 'FooBar', 24 + FOO_BAR2 = 'fooBar', 25 + FOO_BAR3 = 'foo bar' 23 26 } 24 27 25 28 export enum FooEnum2 { 26 29 BAZ = 'baz' 30 + } 31 + 32 + export enum TypeEnum { 33 + FOO = 'foo', 34 + BAR = 'bar' 27 35 } 28 36 29 37 export type GetFooData = {
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline/index.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 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';
+4 -2
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline/types.gen.ts
··· 5 5 }; 6 6 7 7 export type Foo = { 8 - type?: FooEnum; 8 + type?: TypeEnum; 9 9 }; 10 10 11 11 export type Bar = { ··· 14 14 15 15 export type Baz = 'qux' | 'quux'; 16 16 17 - export type FooEnum = 'foo' | 'bar'; 17 + export type FooEnum = 'foo' | 'bar' | 'FooBar' | 'fooBar' | 'foo bar'; 18 18 19 19 export type FooEnum2 = 'baz'; 20 + 21 + export type TypeEnum = 'foo' | 'bar'; 20 22 21 23 export type GetFooData = { 22 24 body?: never;
+10 -6
packages/openapi-ts/src/__tests__/internal.test.ts
··· 1 1 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 + ); 8 12 });
+9 -1
packages/openapi-ts/src/plugins/@hey-api/typescript/shared/export.ts
··· 16 16 plugin: HeyApiTypeScriptPlugin['Instance']; 17 17 schema: IR.SchemaObject; 18 18 }) => { 19 + const keyCounts: Record<string, number> = {}; 19 20 const typeofItems: Array< 20 21 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined' 21 22 > = []; ··· 57 58 ) { 58 59 key = `_${key}`; 59 60 } 61 + 62 + const keyCount = (keyCounts[key] ?? 0) + 1; 63 + keyCounts[key] = keyCount; 64 + 65 + // avoid collision 66 + if (keyCount > 1) { 67 + key = `${key}${keyCount}`; 68 + } 60 69 } 61 - 62 70 return { 63 71 key, 64 72 schema: item,
+1 -1
specs/3.0.x/enum-inline.json
··· 9 9 "Foo": { 10 10 "properties": { 11 11 "type": { 12 - "enum": ["foo", "bar"], 12 + "enum": ["foo", "bar", "FooBar", "fooBar", "foo bar"], 13 13 "type": "string" 14 14 } 15 15 },
+3
specs/3.1.x/enum-inline.yaml
··· 18 18 enum: 19 19 - foo 20 20 - bar 21 + - FooBar 22 + - fooBar 23 + - foo bar 21 24 post: 22 25 responses: 23 26 '200':