elierotenberg / fastify-zod

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

Set schema target to OpenAPI 3 #1

Closed hampuskraft closed 2 years ago

hampuskraft commented 2 years ago

This update upgrades the output JSON schema to OpenAPI 3, replacing anyOf with nullable fields. This change ensures compliance with codegen tools like openapi-typescript. Everything should remain compatible, as it works fine in my app.

hampuskraft commented 2 years ago

Additionally, I've encountered issues with the default $refStrategy. Setting it to 'none' resolves these issues for me without affecting other definitions. The problem arises when a nested object in an anyOf incorrectly references the counterpart in anyOf[0] instead of inlining it, which happens with the default setting. For now, I've copied these functions into my own application and modified them accordingly.

elierotenberg commented 2 years ago

Hi! Thanks for your contribution. I had to slightly modify some details and tests to account for the new target, which is now an option. Released as 0.0.2.