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
Hey, thanks for the neat tool for effortlessly building OpenAPI schemas. I've noticed (or maybe I'm doing something wrong) that middleware with context variables is not inferred at the route level when trying to access the route's context object.
exporttypeAuthMiddlewareEnv={Variables: {user: {id: string;};};};exportconstauthMiddleware=createMiddleware<AuthMiddlewareEnv>(async(c,next)=>{constauthToken=getCookie(c,Config.Cookie.AuthToken);if(!authToken){thrownewHTTPException(401);}const{ sub }=awaitverifyToken(authToken);constuser={id: sub};c.set("user",user);awaitnext();});// ...exportconstgetSessionRoute=createRoute({method: "get",path: "/session",summary: "Get Session",middleware: authMiddleware,
tags,
responses,});// ...constrouter=newOpenAPIHono();router.openapi(getSessionRoute,(c)=>c.json(c.var.user));// Property 'user' does not exist on type 'Readonly<ContextVariableMap & object>'
Thanks in advance!
The text was updated successfully, but these errors were encountered:
Thank you for the issue. When we solve this problem, the type definition inside the Zod OpenAPI may be super complicated or verbose. I think finding a nice workaround is good for this issue, though I don't have an idea now.
Hey, thanks for the neat tool for effortlessly building OpenAPI schemas. I've noticed (or maybe I'm doing something wrong) that middleware with context variables is not inferred at the route level when trying to access the route's context object.
Thanks in advance!
The text was updated successfully, but these errors were encountered: