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

Add --export-types option to generate types for all schemas #206

Closed eli0shin closed 1 year ago

eli0shin commented 1 year ago

I have been regularly hitting the "The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.ts(7056)" error from typescript when generating clients for large schemas. This library does support generating types but reserves that feature for circular types. This PR adds a non-breaking option to enable TS type generation for all schemas.

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 4:13am
astahmer commented 1 year ago

I don't have a strong opinion on this, but couldnt this be possible with a custom template already ?

also, this is the default behaviour with https://typed-openapi-astahmer.vercel.app/

eli0shin commented 1 year ago

Thank you for the quick merge! While it was previously possible with a custom template to export the types that were generated for recursive types. No plain TS types were generated for non-recursive types. I am using a custom template and have broken the schema down as far as possible, generating types in the template wherever I can. Some of the schemas are still large enough that 1 or 2 nodes can't be inferred which means I can't generate a .d.ts from the client.

astahmer commented 1 year ago

oh ok, I see the issue you had. out of curiosity, do you reproduce the issue with typed-openapi ?