HonoH
Hono8mo ago
wyrd

Why does .openapi(route, handler) return unknown type in client.ts when using OpenAPIHono?

I’m new to Hono and trying out @hono/zod-openapi for the first time.

Im trying out the RPC feature with client.ts

I noticed that when I define my routes like this
const app = new OpenAPIHono()
app.openapi(getTodosRoute, (c) => {
  // handler logic
})

client is type unkown
But when I chain the .openapi(...) calls like this:
const app = new OpenAPIHono()
  .openapi(getTodosRoute, async (c) => { /* handler */ })
  .openapi(getTodoByIdRoute, async (c) => { /* handler */ })

the types are inferred correctly in client.ts.
Why is there a difference? Is this expected behavior with OpenAPIHono, or am I missing something in how route types are collected?
Here is my full code
https://pastebin.com/dyeYHung
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Was this page helpful?