elierotenberg / fastify-zod

Zod integration with Fastify
MIT License
212 stars 19 forks source link

feat: allow passing a refStrategy option to zod-to-json-schema #42

Open jltwheeler opened 1 year ago

jltwheeler commented 1 year ago

Currently, when using openapi-typescript-codegen to consume the generated openapi.json file from fastify-zod for my frontend, I encounter difficulties due to the incompatibility between the codegen types and the default refStrategy options options used in zod-to-json-schema.

To overcome this limitation and improve the integration between these two amazing tools (great work btw 😄), I propose the addition of a new refStrategy option in the buildJSONSchema options and pass this down to zod-to-json-schema.

Also, given this is just the addition of a passthrough prop, I didn't think writing a whole test for this was necessary 😅

Thanks!