How to properly use extendZodWithOpenApi(z) #292
Unanswered
ajiohjesse
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to build an express starter template with this library but I have a few issues.
The docs say to call the extendZodWithOpenApi(z) function in a common entry point which I did, inside my server.ts file but it doesn't work. I ended up having to call the function in two more random files (i.e docs.ts and another post.schema.ts file) to get it to work but I'm sure this is not a recommended pattern as stated in the docs to only call the function once.
My setup is this: my docs.ts file does the actual generation of the openapi document while I have several *.registry.ts files that register the components and component paths, and also *.schema.ts files where I define reusable zod schemas for both for validation and for usage with the openapi registries.
I tried creating a zod-extend.ts file and using this solution:
It works in dev because I'm using tsx but the production build still throws the error
.openApi is not a function.I just want to understand how to set this up properly.
Beta Was this translation helpful? Give feedback.
All reactions