zod-to-openapi icon indicating copy to clipboard operation
zod-to-openapi copied to clipboard

zod lazy

Open 121lipe121 opened this issue 1 year ago • 11 comments

is there any chance or plan for supporting zod lazy method? we really need it, we've dropped an from using it for that

121lipe121 avatar Jul 10 '24 18:07 121lipe121

I also need this really hard, would it be difficult to implement?

leognmotta avatar Jul 10 '24 21:07 leognmotta

i second that

setcooki avatar Jul 28 '24 15:07 setcooki

Same here 👍

The use case:

  • Using Prisma as an ORM to define DB models
  • Using Zod to validate user requests
  • Using zod-prisma-types package 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

mindbend0x avatar Aug 22 '24 22:08 mindbend0x

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.

AGalabov avatar Sep 13 '24 06:09 AGalabov

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

MalinnaLeach avatar Apr 25 '25 15:04 MalinnaLeach

@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 avatar Jun 18 '25 15:06 lucascurti

@lucascurti YeeP79 also mentioned to be interested fyi here: https://github.com/asteasolutions/zod-to-openapi/issues/300

flipvh avatar Jun 18 '25 16:06 flipvh

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 🤞

lucascurti avatar Jun 18 '25 16:06 lucascurti

Draft PR: https://github.com/asteasolutions/zod-to-openapi/pull/314

lucascurti avatar Jun 18 '25 19:06 lucascurti

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 avatar Aug 27 '25 06:08 maxmil

@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.

lucascurti avatar Aug 27 '25 06:08 lucascurti