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
Thanks for a neat library! I've been building an app starting on the Cloudflare open api template which uses chanfana and hono.
I quite like the setup and the api docs get generated and served nicely. But I'd also like to use hono's rpc client for testing and to consume the api and here I am unable to get the autocomplete and types to function properly.
I don't fully understand the magic behind the spec sharing there, so I'm not 100% sure which type you need to export to get the router. Using the chanfana HonoOpenAPIRouterType compiles without error but doesn't share the spec correctly with the client.
// add this to index.tsexporttypeAppType=typeofopenapi
What I then get in the client:
What I want (and how it works if I use hono.route to set up the routes, as per the hono docs):
I thought maybe this was related to the issue about nested routes (#179) (which you also need to handle in plain hono), but removing the /api path prefix does not fix it for me.
Am I missing something here or is this not possible when using chanfana and class based endpoints?
Full steps to reproduce:
Create a template app using the Cloudflare cli:
npm create cloudflare@latest
╭ Create an application with Cloudflare Step 1 of 3
│
├ In which directory do you want to create your application?
│ dir ./shiny-disk-6177
│
├ What would you like to start with?
│ category Application Starter
│
├ Which template would you like to use?
│ type API starter (OpenAPI compliant)
│
├ Copying template files
│ files copied to project directory
│
├ Installing dependencies
│ installed via `npm install`
│
╰ Application created
Add the following to your index.ts to export the route type to share the api spec with a client:
exporttypeAppType=typeofopenapi
Then try adding a client.ts file to consume the api with the following code:
Thanks for a neat library! I've been building an app starting on the Cloudflare open api template which uses chanfana and hono.
I quite like the setup and the api docs get generated and served nicely. But I'd also like to use hono's rpc client for testing and to consume the api and here I am unable to get the autocomplete and types to function properly.
I don't fully understand the magic behind the spec sharing there, so I'm not 100% sure which type you need to export to get the router. Using the chanfana
HonoOpenAPIRouterType
compiles without error but doesn't share the spec correctly with the client.What I then get in the client:
What I want (and how it works if I use
hono.route
to set up the routes, as per the hono docs):I thought maybe this was related to the issue about nested routes (#179) (which you also need to handle in plain hono), but removing the
/api
path prefix does not fix it for me.Am I missing something here or is this not possible when using chanfana and class based endpoints?
Full steps to reproduce:
index.ts
to export the route type to share the api spec with a client:Your IDE will not surface the same autocomplete and type information as if you had just used pure hono.
The text was updated successfully, but these errors were encountered: