Skip to content

Fix Zod v4 oneOf unions in strict schemas#1896

Merged
HAYDEN-OAI merged 3 commits into
openai:mainfrom
kiwigitops:fix-zod-oneof-strict-schema
Jun 24, 2026
Merged

Fix Zod v4 oneOf unions in strict schemas#1896
HAYDEN-OAI merged 3 commits into
openai:mainfrom
kiwigitops:fix-zod-oneof-strict-schema

Conversation

@kiwigitops

Copy link
Copy Markdown
Contributor

Closes #1709

Zod v4 can emit oneOf for discriminated unions, but strict OpenAI schemas support anyOf instead. This converts oneOf unions before the existing strict-schema recursion runs, so nested discriminated unions are still processed normally.

Verification:

  • yarn jest tests/helpers/zod.test.ts --runInBand
  • yarn jest tests/lib/transform.test.ts tests/helpers/zod.test.ts --runInBand
  • git diff --check

@kiwigitops kiwigitops requested a review from a team as a code owner May 23, 2026 05:51

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6713349141

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/lib/transform.ts Outdated

Copy link
Copy Markdown
Contributor Author

Quick follow-up on this. The oneOf semantics issue was addressed in the latest commit; happy to adjust the schema transform or test coverage if this needs a different shape.

@HAYDEN-OAI

Copy link
Copy Markdown
Contributor

@kiwigitops thanks for sticking with this and for getting the original fix moving. appreciate your patience while we worked through the schema semantics and brought the branch current. merging now! 💚

@HAYDEN-OAI HAYDEN-OAI merged commit 039954b into openai:main Jun 24, 2026
10 checks passed
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.

Zod schema conversion broken for unions in Zod 4.1.13+

3 participants