-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Followed the example and failed #17
Comments
Hello @nazarEnzo , I tried your code without the
I see nothing in your code that would cause this error. Maybe some additional info like what command are you using to execute this code would help. |
Hello @AGalabov, Thank you for your reply! I tried it with ts-node and it works. For some reason it is not functioning in the NextJs environment. How to replicate:
P.S It works without schemes, parameters and paths Thank you! |
It seems that the problem is coming from Alternatively - I would imagine that your common use case would not be to generate the documentation runtime (on each call of the api) but rather build time. So if you do that once (when building) with a script using |
Just to expand on what @AGalabov mentioned, it's related to this issue: https://www.dannyguo.com/blog/how-to-fix-instanceof-not-working-for-custom-errors-in-typescript/ |
Okay, so I investigated a bit and the problem seems to be different. Somehow the zod instances that (1) the lib uses ( |
@AGalabov If I don't find a config change that helps this case the fallback fix would be to use |
I figured out the problem. Just need to figure out the solution now :) Here's some technical stuff if someone is interestedLooking at the compiled code emitted by webpack, I see this:
Notice how
we see that So what happens is:
Here's a test script to illustrate the problem:
The output is So solutions would be:
It's probably best to implement both, I'll see if I can open a PR soon. |
The change is to make zod-to-openapi independent of a specific Zod instance. See #17 (comment)
@nazarEnzo Should be fixed in v1.2.2, can you please confirm? Thank you for the report and the reproduction steps |
Hi. I followed the example and got the following error:
when trying to use
registry.registerParameter
,registry.register
,registry.registerPath
in NextJS api route.My package.json:
My code:
What am I doing wrong?
The text was updated successfully, but these errors were encountered: