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 chaining approach needed for Hono RPC with a middleware, OpenApiHono specific methods do not exist on the chain anymore after using use, because use returns Hono instead of OpenApiHono.
Ideally these kind of issues would be solved by returning this from the base hono class, but we would need to pass on the modified generics to this, which is not supported by typescript yet. That means every Hono method should be repesented in the OpenAPIHono class definition as well, but with OpenAPIHono as the return type. To fix this issue it looks like we need to add the use method with the proper return type to the OpenAPIHono type declaration.
The text was updated successfully, but these errors were encountered:
hpohlmeyer
changed the title
@hono/zod-openapi returns wrong type from use
[zod-openapi] returns wrong type from useNov 25, 2024
hpohlmeyer
changed the title
[zod-openapi] returns wrong type from use
[zod-openapi] Wrong return type from useNov 25, 2024
That's right, OpenAPIHono does not provide that feature due to the limitations of Hono's type definitions. It will have to be redefined in OpenAPIHono.
constapp=newOpenAPIHono().use('*',cors({origin: [process.env.DASHBOARD_URL],credentials: true})).route('/',mainRouter);constport=getPortFromURL(process.env.API_URL,3000);serve({fetch: app.fetch, port }).on('listening',()=>{console.log(`>>> API running on ::${port}`);});
When using the chaining approach needed for Hono RPC with a middleware,
OpenApiHono
specific methods do not exist on the chain anymore after usinguse
, becauseuse
returnsHono
instead ofOpenApiHono
.Ideally these kind of issues would be solved by returning
this
from the base hono class, but we would need to pass on the modified generics tothis
, which is not supported by typescript yet. That means every Hono method should be repesented in theOpenAPIHono
class definition as well, but withOpenAPIHono
as the return type. To fix this issue it looks like we need to add theuse
method with the proper return type to theOpenAPIHono
type declaration.The text was updated successfully, but these errors were encountered: