Skip to content

fix(zod): avoid adding redundant not to optional schemas #1593

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

Merged
merged 1 commit into from
Jul 22, 2025

Conversation

bigint
Copy link
Contributor

@bigint bigint commented Jul 22, 2025

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

  • Adjusted optional field handling so that JSON Schema generation no longer emits redundant “not” constraints when an optional property is nested inside an object. The parser now checks that the current path begins with the property path before omitting the “not” clause

  • Updated the test snapshot to match the corrected schema output, where optional nullable enums only include the union of the enum type and null without the extra “not” block

Additional context & links

Fixes #1365

@bigint bigint requested a review from a team as a code owner July 22, 2025 10:46
Copy link
Collaborator

@RobertCraigie RobertCraigie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@RobertCraigie RobertCraigie changed the base branch from master to next July 22, 2025 15:45
@RobertCraigie RobertCraigie changed the title fix: zod optional schema fix(zod): avoid adding redundant not to optional schemas Jul 22, 2025
@RobertCraigie RobertCraigie merged commit 162b697 into openai:next Jul 22, 2025
4 of 5 checks passed
@stainless-app stainless-app bot mentioned this pull request Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

zodResponseFormat outputs a weird anyOf that causes an exception
2 participants