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
When using the following code to set up a route, the route appears in the Swagger documentation but results in a 404 error when accessed:
constapp=newOpenAPIHono<WorkerHonoContext>();app.route("/api/v1/users/",usersHono);exportconstusersHono=newOpenAPIHono<WorkerHonoContext>();registerUserWebsocketRoute(usersHono);exportconstUserWebsocketRoute=createRoute({tags: ["User"],summary: "User Websocket",method: "post",path: "{userId}/websocket",request: {cookies: CookiesSchema,params: ParamsSchema,headers: HeadersSchema,},responses: {"1001": {description: "WebSocket has been upgraded"},"400": ZodErrorResponseConfig,"429": ZodErrorResponseConfig,},});userHono.openapi(UserWebsocketRoute,async(c)=>{
...
});
Expected Behavior
The route should be accessible, as it is correctly displayed in the Swagger documentation.
Actual Behavior
Attempting to access this route returns a 404 error.
Solution
The route becomes accessible if the following adjustments are made:
Update the subrouter registration:
app.route("/api/v1/users",usersHono);
Adjust the path format in the UserWebsocketRoute:
path: "/{userId}/websocket",
Additional Context
It seems that the trailing slash in the route definition (/api/v1/users/) and the missing leading slash in UserWebsocketRoute's path may be causing the routing issue.
The text was updated successfully, but these errors were encountered:
Issue Summary
When using the following code to set up a route, the route appears in the Swagger documentation but results in a 404 error when accessed:
Expected Behavior
The route should be accessible, as it is correctly displayed in the Swagger documentation.
Actual Behavior
Attempting to access this route returns a 404 error.
Solution
The route becomes accessible if the following adjustments are made:
Update the subrouter registration:
Adjust the path format in the
UserWebsocketRoute
:Additional Context
It seems that the trailing slash in the route definition (
/api/v1/users/
) and the missing leading slash inUserWebsocketRoute
's path may be causing the routing issue.The text was updated successfully, but these errors were encountered: