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
You can request /v1 which will respond correctly, but in the final openapi document the route is generated as the following: /v1/ which results in scalar, swagger and other such tools to use the wrong path for requesting the endpoint.
On the Zod Openapi middleware it will provide the following paths to mergePath: mergePath("/", "/v1", "/") which results in this /v1/.
It seems the issue comes from these lines, since after the first iteration the p variable is now /, and then this condition is true.
What version of Hono are you using?
4.7.0
What runtime/platform is your app running on? (with version if possible)
Cloudflare Workers
What steps can reproduce the bug?
This issue mainly happens when you combine Hono with Hono's Zod Openapi, but since the issue is coming from Hono itself i have created the issue here.
By using this code here:
You can request
/v1
which will respond correctly, but in the final openapi document the route is generated as the following:/v1/
which results in scalar, swagger and other such tools to use the wrong path for requesting the endpoint.On the Zod Openapi middleware it will provide the following paths to
mergePath
:mergePath("/", "/v1", "/")
which results in this/v1/
.It seems the issue comes from these lines, since after the first iteration the p variable is now
/
, and then this condition is true.hono/src/utils/url.ts
Lines 145 to 148 in 6ceb1ab
What is the expected behavior?
The openapi document should not have
/v1/
but instead/v1
.What do you see instead?
That the openapi document has
/v1/
and not/v1
Additional information
It seems to only happen when there is a route with only
/
as the path.The text was updated successfully, but these errors were encountered: