Skip to content
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

Implement Zod: discriminatedUnion #1906

Closed
Georgegriff opened this issue Feb 17, 2025 · 2 comments · Fixed by #1907
Closed

Implement Zod: discriminatedUnion #1906

Georgegriff opened this issue Feb 17, 2025 · 2 comments · Fixed by #1907
Assignees
Labels
zod Zod related issue
Milestone

Comments

@Georgegriff
Copy link
Contributor

Hello, I notice currently the openapi discriminator with mapping when used with "oneOf" does not generatezod.discriminatedUnioncode, they instead chainor's` which can result in slightly wrong error messages from zod. Is there a reason this was avoided or could it make sense?

I'm happy to investigate implementing, just thought I'd ask first, i'm not sure if doing so would be a breaking change or a correction.

@melloware melloware added the zod Zod related issue label Feb 17, 2025
@melloware
Copy link
Collaborator

Feel free to investigate and provide a PR!

@Georgegriff
Copy link
Contributor Author

Georgegriff commented Feb 18, 2025

started working on it, running the code locally comes with some challenges:

Error [ERR_REQUIRE_ESM]: require() of ES Module /.../node_modules/ansi-styles/index.js from /.../orval/packages/core/node_modules/chalk/source/index.js not supported.

Was trying to run one of the samples to get a feel for how the code works

EDIT: fixed, had to recursively delete my node_modules folder and then re-run yarn install. PAIN!

@melloware melloware added this to the 7.6.0 milestone Feb 18, 2025
@Georgegriff Georgegriff changed the title Zod: discriminatedUnion Implement Zod: discriminatedUnion Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
zod Zod related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants