astahmer / openapi-zod-client

Generate a zodios (typescript http client with zod validation) from an OpenAPI spec (json/yaml)
openapi-zod-client.vercel.app
717 stars 80 forks source link

fix: discriminatedUnion allOf issue #249

Closed nmcdaines closed 8 months ago

nmcdaines commented 8 months ago

An issue was previously raised #110 whereby the z.discriminatedUnion caused issues in the gererated schema.

It appears the issue is caused by the z.and type, this breaks inference when used within a z.discriminatedUnion.

In order to solve this, whenever there are multiple objects defined within an allOf block we should instead opt to use a z.union type instead; which then allows the z.and type to be infered correctly.

vercel[bot] commented 8 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
openapi-zod-client ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2023 10:22pm
astahmer commented 8 months ago

hey, thank you for working on this ! could you add a a changeset ?

nmcdaines commented 8 months ago

Hey @astahmer, thanks for reviewing and apologies for not including a changeset 🙏 I've amended my previous commit to include a changeset 👍