cloudflare / cloudflare/chanfana
Nested route with HonoJS should have better documentations
- Dominant language
- TypeScript
- Stars
- 766
- Forks
- 70
- Avg merge
- 25m
- Merged PRs (30d)
- 4
Description
I just get confused as a 🔥Hono user. My issue is in the comment in the code.
```ts
const api = new Hono();
const openapi = fromHono(api, {
// only use "base" option if schema.servers do not append nested route, like "https://api.example.com"
// and okay with /v1/ everywhere on the Swagger UI
// base: "/v1",
// but here it is okay either use "/docs" or "docs",
docs_url: "/docs",
// must not use the default "/openapi.json" will not work
openapi_url: 'openapi.json',
schema: {
servers: [
{
// this must be set and the append the nested route, or "Try it out" button will break
url: 'https://api.example.com/v1',
}
]
}
});
// the final url for this endpoint will be "https://api.example.com/v1/api/tasks"
openapi.get("/api/tasks", TaskList);
const app = new Hono();
app.route('/v1', api);
```
Contributor guide
Research direction
Start with the fromHono configuration and the nested app.route('/v1', api) example shown in the issue. Document how docs_url, openapi_url, schema.servers, and the nested route combine, including the resulting endpoint URL and the conditions that keep Swagger UI's Try it out working.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100