astahmer / openapi-zod-client

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

Export only object types with --export-types flag, fix boolean options in playground #212

Closed eli0shin closed 1 year ago

eli0shin commented 1 year ago

With the new --export-types flag, all schema are defined as TS types as well. The schema definition included a type assignment to the generated type. This is useful for schemas that are too large for TS to infer like deeply nested objects. OpenApi supports minimum, maximum, minLength, minItems, etc. which are transpiled to the zod .min(), .max(), etc. methods on the schema. These methods are not supported on z.ZodType types which causes a TS error when schemas are a non-object type and have these validation attributes on them. This PR limits the OpenApi types for which non-circular types will be generated when --export-types is passed to only object types.

Additionally, the boolean lib option in the playground has been broken. This PR properly sets booleans in options when the lib options are saved.

vercel[bot] commented 1 year 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 Aug 18, 2023 9:24pm