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

Type intersections using allOf with required keys does not result in required properties #291

Open
mithodin opened this issue May 17, 2024 · 0 comments

Comments

@mithodin
Copy link

Describe the bug
I think this a regression of the issue described in #260 (which is closed as resolved). When intersecting two schemas using allOf, where one of the schemas adds a required constraint to a property defined by the other scheme, the constraint is not represented in the generated code.

Minimal reproduction
https://openapi-zod-client.vercel.app/?doc=PYBwpgdghiCWBcACAzAOgAyuQKFhAZsPNoogC6xkA2YSAogB5QC2IN2IUZAFgM7GkA9GTC8yA0ogDmYcSUmkATqJDAIvURIWkATOnRbtpAMZqREOUaMw2sY11hrBAK15rDVyb2PcwzKB6ekgAkyvhIAOQAxIKmrGqQZLyC3r7%2ByQAqAJ7gAEIR2HGqEIn88ql%2BUGUK2eAAgoFkObSIwABGzmDGZPIKIIqgYIoUmr3aAWNGTeBIeCIyipOSbYEK0y1zYAtjtWC5gVBUVADy4UukALTkzUjtnd3nksoAjgCusMoAJqvaV1CPV1CYHCiGisWA8RKFmSFXSgl2dQiQA

Expected behavior
In the given example, I would expect the resulting types to be

const TypeA = z.object({ a: z.number().int(), b: z.number().int() }).partial().passthrough();
const TypeB = TypeA.required({ a: true });

or something to the same effect.

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

No branches or pull requests

1 participant