-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1336 from hey-api/fix/transformers-any-of-null
fix: experimental parser transforms anyOf date and null
- Loading branch information
Showing
15 changed files
with
328 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@hey-api/openapi-ts': patch | ||
--- | ||
|
||
fix: experimental parser transforms anyOf date and null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/openapi-ts/test/__snapshots__/3.0.x/transformers-any-of-null/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
export * from './types.gen'; | ||
export * from './transformers.gen'; |
20 changes: 20 additions & 0 deletions
20
packages/openapi-ts/test/__snapshots__/3.0.x/transformers-any-of-null/transformers.gen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
|
||
import type { GetFooResponse } from './types.gen'; | ||
|
||
const fooSchemaResponseTransformer = (data: any) => { | ||
if (data.foo) { | ||
data.foo = new Date(data.foo); | ||
} | ||
if (data.bar) { | ||
data.bar = new Date(data.bar); | ||
} | ||
return data; | ||
}; | ||
|
||
export const getFooResponseTransformer = async (data: any): Promise<GetFooResponse> => { | ||
data = data.map((item: any) => { | ||
return fooSchemaResponseTransformer(item); | ||
}); | ||
return data; | ||
}; |
20 changes: 20 additions & 0 deletions
20
packages/openapi-ts/test/__snapshots__/3.0.x/transformers-any-of-null/types.gen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
|
||
export type Foo = { | ||
foo?: string; | ||
bar?: string | null; | ||
}; | ||
|
||
export type GetFooData = { | ||
body?: never; | ||
url: '/foo'; | ||
}; | ||
|
||
export type GetFooResponses = { | ||
/** | ||
* OK | ||
*/ | ||
200: Array<Foo>; | ||
}; | ||
|
||
export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; |
3 changes: 3 additions & 0 deletions
3
packages/openapi-ts/test/__snapshots__/3.1.x/transformers-any-of-null/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
export * from './types.gen'; | ||
export * from './transformers.gen'; |
23 changes: 23 additions & 0 deletions
23
packages/openapi-ts/test/__snapshots__/3.1.x/transformers-any-of-null/transformers.gen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
|
||
import type { GetFooResponse } from './types.gen'; | ||
|
||
const fooSchemaResponseTransformer = (data: any) => { | ||
if (data.foo) { | ||
data.foo = new Date(data.foo); | ||
} | ||
if (data.bar) { | ||
data.bar = new Date(data.bar); | ||
} | ||
if (data.baz) { | ||
data.baz = new Date(data.baz); | ||
} | ||
return data; | ||
}; | ||
|
||
export const getFooResponseTransformer = async (data: any): Promise<GetFooResponse> => { | ||
data = data.map((item: any) => { | ||
return fooSchemaResponseTransformer(item); | ||
}); | ||
return data; | ||
}; |
Oops, something went wrong.