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 #257 to infer as object when only required array set #258

Closed marrowleaves closed 8 months ago

marrowleaves commented 8 months ago

This is an attempt to fix #257

Now getZodSchema would treat schema object with required defined as an array of type object and correctly infer the type. The fix also checks extra properties in required array but not defined in properties, inferred as additional props.

The fix doesn't handle the case when additionalProperties are defined and mixed with required array. It seems that the current implementation doesn't handle the mix of additionalProperties and properties either. But it would be easy to append the extraProperties string generated from required to the code string generated for additionalProperties, after it's properly handled.

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 21, 2023 0:40am
astahmer commented 8 months ago

thank you for working on this ! could you add a changeset so I can merge it ?

marrowleaves commented 8 months ago

thank you for working on this ! could you add a changeset so I can merge it ?

Sure, changeset text generated