Skip to content

Commit f3d2d32

Browse files
authored
Merge pull request #2034 from Le0Developer/feat/typeids
2 parents d687cdd + 257dd07 commit f3d2d32

File tree

19 files changed

+189
-15
lines changed

19 files changed

+189
-15
lines changed

.changeset/clean-kiwis-worry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/openapi-ts": patch
3+
---
4+
5+
fix(typescript): add support for TypeID types

packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
export type Foo = {
44
bar?: number;
55
foo: bigint;
6-
id: string;
6+
id: UserId;
77
};
88

99
export type Bar = {
@@ -27,6 +27,10 @@ export type PostFooResponses = {
2727

2828
export type PostFooResponse = PostFooResponses[keyof PostFooResponses];
2929

30+
export type TypeID<T extends string> = `${T}_${string}`;
31+
32+
export type UserId = TypeID<'user'>;
33+
3034
export type ClientOptions = {
3135
baseUrl: string;
3236
};

packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/types.gen.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
export type Foo = {
44
bar?: number;
55
foo: bigint;
6-
id: string;
6+
id: UserId;
77
};
88

99
export type Bar = {
@@ -27,6 +27,10 @@ export type PostFooResponses = {
2727

2828
export type PostFooResponse = PostFooResponses[keyof PostFooResponses];
2929

30+
export type TypeID<T extends string> = `${T}_${string}`;
31+
32+
export type UserId = TypeID<'user'>;
33+
3034
export type ClientOptions = {
3135
baseUrl: string;
3236
};

packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
export type Foo = {
44
bar?: number;
55
foo: bigint;
6-
id: string;
6+
id: UserId;
77
};
88

99
export type Bar = {
@@ -27,6 +27,10 @@ export type PostFooResponses = {
2727

2828
export type PostFooResponse = PostFooResponses[keyof PostFooResponses];
2929

30+
export type TypeID<T extends string> = `${T}_${string}`;
31+
32+
export type UserId = TypeID<'user'>;
33+
3034
export type ClientOptions = {
3135
baseUrl: `${string}://${string}` | (string & {});
3236
};

packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/types.gen.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
export type Foo = {
44
bar?: number;
55
foo: bigint;
6-
id: string;
6+
id: UserId;
77
};
88

99
export type Bar = {
@@ -27,6 +27,10 @@ export type PostFooResponses = {
2727

2828
export type PostFooResponse = PostFooResponses[keyof PostFooResponses];
2929

30+
export type TypeID<T extends string> = `${T}_${string}`;
31+
32+
export type UserId = TypeID<'user'>;
33+
3034
export type ClientOptions = {
3135
baseUrl: `${string}://${string}` | (string & {});
3236
};

packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
export type Foo = {
44
bar?: number;
55
foo: bigint;
6-
id: string;
6+
id: UserId;
77
};
88

99
export type Bar = {
@@ -27,6 +27,10 @@ export type PostFooResponses = {
2727

2828
export type PostFooResponse = PostFooResponses[keyof PostFooResponses];
2929

30+
export type TypeID<T extends string> = `${T}_${string}`;
31+
32+
export type UserId = TypeID<'user'>;
33+
3034
export type ClientOptions = {
3135
baseUrl: `${string}://${string}` | (string & {});
3236
};

packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/types.gen.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
export type Foo = {
44
bar?: number;
55
foo: bigint;
6-
id: string;
6+
id: UserId;
77
};
88

99
export type Bar = {
@@ -27,6 +27,10 @@ export type PostFooResponses = {
2727

2828
export type PostFooResponse = PostFooResponses[keyof PostFooResponses];
2929

30+
export type TypeID<T extends string> = `${T}_${string}`;
31+
32+
export type UserId = TypeID<'user'>;
33+
3034
export type ClientOptions = {
3135
baseUrl: `${string}://${string}` | (string & {});
3236
};

packages/openapi-ts-tests/test/spec/2.0.x/type-format.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ definitions:
2424
type: integer
2525
id:
2626
type: string
27+
format: typeid
28+
example: 'user_123'
2729
required:
2830
- id
2931
- foo

packages/openapi-ts-tests/test/spec/3.0.x/type-format.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ components:
2525
type: integer
2626
id:
2727
type: string
28+
format: typeid
29+
example: 'user_123'
2830
required:
2931
- id
3032
- foo

packages/openapi-ts-tests/test/spec/3.1.x/type-format.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ components:
2525
type: integer
2626
id:
2727
type: string
28+
format: typeid
29+
example: 'user_123'
2830
required:
2931
- id
3032
- foo

0 commit comments

Comments
 (0)