zod-to-openapi
zod-to-openapi copied to clipboard
zod lazy
is there any chance or plan for supporting zod lazy method? we really need it, we've dropped an from using it for that
I also need this really hard, would it be difficult to implement?
i second that
Same here 👍
The use case:
- Using Prisma as an ORM to define DB models
- Using Zod to validate user requests
- Using
zod-prisma-typespackage to auto generate Zod types based on Prisma schemas
Issue:
The zod-prisma-types package uses recursive schemas and .lazy and unable to include those generated schemas in the OpenApi registry
Please see my comment here
In general we are open to implement it, however it would presumably require some overhaul of our code base. Considering the amount of free time that we have to maintain this library I am not sure when that could come. If any of you is open to the idea, you can try and open up a PR.
Would be really keen for this! Would this new feature in the zod 4 beta potentially ease support for recursive schema..? https://v4.zod.dev/v4#true-recursive-types
@AGalabov I will give this one a try on the latest v4 branch. It might take some time to get familiar with the codebase but feel free to let me know if you have any rough idea of how you think this should be implemented.
@lucascurti YeeP79 also mentioned to be interested fyi here: https://github.com/asteasolutions/zod-to-openapi/issues/300
Thanks @flipvh! 🙌 The comment in that issue really helps. I'm taking a similar approach. Adding some tests and they are passing, but I'll add a bunch more of tests and share a draft as soon as I'm certain everything is working 🤞
Draft PR: https://github.com/asteasolutions/zod-to-openapi/pull/314
It looks like that PR was closed until you find more time to work on it @lucascurti
In case you are lacking motivation we are also very interested in this feature. In particular the ability to define recursive types in schemas.
@maxmil I don't think I'll have time to work on it until around October. I'm happy to collaborate if you want to help get it to the finish line.