-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: Add support for zod@4 schemas #1666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
8f56474
7be8d10
cbf5f81
6b4ae77
a1a4718
19713bf
747c0df
284cfe7
7a98adb
98e5b8c
a324c80
a532410
f3ab503
946a7b0
d4aaef9
2ddb9c9
704ba4c
1192cb2
646c820
dfed1f0
195a6ed
79a8c53
2fbb1ce
ddeb05e
95ce1a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,11 @@ | ||
| import { zodResponseFormat } from 'openai/helpers/zod'; | ||
| import { z } from 'zod/v3'; | ||
| import { z as zv3 } from 'zod/v3'; | ||
| import { z as zv4 } from 'zod'; | ||
|
|
||
| describe('zodResponseFormat', () => { | ||
| describe.each([ | ||
| { version: 'v3', z: zv3 as any }, | ||
| { version: 'v4', z: zv4 as any }, | ||
|
RobertCraigie marked this conversation as resolved.
Outdated
|
||
| ])('zodResponseFormat (Zod $version)', ({ version, z }) => { | ||
|
Comment on lines
+5
to
+8
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👌 this is a cool way to test things |
||
| it('does the thing', () => { | ||
| expect( | ||
| zodResponseFormat( | ||
|
|
@@ -286,7 +290,7 @@ describe('zodResponseFormat', () => { | |
| `); | ||
| }); | ||
|
|
||
| it('throws error on optional fields', () => { | ||
| (version === 'v4' ? it.skip : it)('throws error on optional fields', () => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as we transform the schema, we actually add missing fields in
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm I don't think this is quite right, in Python it's fine because the property being omitted or explicitly set to so if we add properties that are the equivalent behaviour here for python would be to only add properties to |
||
| expect(() => | ||
| zodResponseFormat( | ||
| z.object({ | ||
|
|
@@ -301,7 +305,7 @@ describe('zodResponseFormat', () => { | |
| ); | ||
| }); | ||
|
|
||
| it('throws error on nested optional fields', () => { | ||
| (version === 'v4' ? it.skip : it)('throws error on nested optional fields', () => { | ||
| expect(() => | ||
| zodResponseFormat( | ||
| z.object({ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.