-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
base: next
Are you sure you want to change the base?
Changes from 1 commit
8f56474
7be8d10
cbf5f81
6b4ae77
a1a4718
19713bf
747c0df
284cfe7
7a98adb
98e5b8c
a324c80
f3ab503
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 }, | ||
])('zodResponseFormat (Zod $version)', ({ version, z }) => { | ||
Comment on lines
+5
to
+8
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', () => { | ||
|
||
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.