You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is unexpected is that the files that are imported from paths api/workspace/src/functions and workspace/src/functions (sibling to /api/) DO NOT get registered in the Open API schema or in the Scalar GUI, yet the routes DO work, with Zod validation and everything.
http://localhost:8000/api/healthcheck1?text=world is the file from api/src/functions/healthcheck. It shows up in the schema / GUI, and shows correct Zod validation behavior.
http://localhost:8000/api/healthcheck2?text=world and http://localhost:8000/api/healthcheck3?text=world are the other two routes from the other import paths.
They function correctly, but do not show up in the schema.
I've also noticed that the 2nd one shows up when I run the code in my local terminal, but not when I run the code inside a devcontaniner. Not sure what the significance of that would be.
What do you see instead?
2 of 3 routes are missing from Open API schema.
Additional information
What gives? I am not sure how to debug this.
Is there some way of forcing the createRoute method from @hono/zod-openapi to output some kind of log about the success/failure of converting the Zod schema to openapi spec?
I'm at a loss as to how to move forward, since it is not working.
The text was updated successfully, but these errors were encountered:
It's not a bug. The OpenAPIHono uses instanceof OpenAPIHono, and the module.default should always be true, but it sometimes will be false because maybe you use dynamic import (I don't know the actual cause).
for(constfnoffunctionsWithPath){functionsetupRoute(module: any){console.log('Mounting function # '+current+' of '+total+'/api/'+fn.name+'\n'+fn.path+'\n\n')// should be true but it's not always trueconsole.log(module.defaultinstanceofOpenAPIHono)// ...awaitimport(fn.path).then(async(module)=>setupRoute(module)).catch((error)=>console.log(error))}
It might be possible to have the app contain a string or other data that can be used to identify whether or not it is an OpenAPI instead of using instanceof, but anyway, this kind of complex usage is not intended or supported.
Which middleware has the bug?
@hono/zod-openapi
What version of the middleware?
^0.18.3
What version of Hono are you using?
^0.2.1
What runtime/platform is your app running on? (with version if possible)
Node
What steps can reproduce the bug?
Console should output something like:
What is the expected behavior?
I have split my app up into several child-apps so that I can load them programmatically.
The files in
api/src/functions
are correctly imported, routes are mounted/served, with working input validation from Zod.They also show up in the Open API spec (at http://localhost:8000/api/openapi-spec.json) as well as in the Scalar GUI (http://localhost:8000/api/). As expected.
What is unexpected is that the files that are imported from paths
api/workspace/src/functions
andworkspace/src/functions
(sibling to/api/
) DO NOT get registered in the Open API schema or in the Scalar GUI, yet the routes DO work, with Zod validation and everything.http://localhost:8000/api/healthcheck1?text=world
is the file fromapi/src/functions/healthcheck
. It shows up in the schema / GUI, and shows correct Zod validation behavior.http://localhost:8000/api/healthcheck2?text=world
andhttp://localhost:8000/api/healthcheck3?text=world
are the other two routes from the other import paths.They function correctly, but do not show up in the schema.
I've also noticed that the 2nd one shows up when I run the code in my local terminal, but not when I run the code inside a devcontaniner. Not sure what the significance of that would be.
What do you see instead?
2 of 3 routes are missing from Open API schema.
Additional information
What gives? I am not sure how to debug this.
Is there some way of forcing the
createRoute
method from@hono/zod-openapi
to output some kind of log about the success/failure of converting the Zod schema to openapi spec?I'm at a loss as to how to move forward, since it is not working.
The text was updated successfully, but these errors were encountered: