How to add swagger to hono api
I want to add a swagger doc to my API and when I add middleware to any new OpenAPIHono instance the ".openapi" method disappears.
this is my factory method. the instance returned doesn't have ".openapi' on it so I can pass my schema returned by createRoute().
Solution:Jump to solution
turns out you have to break it up and it works
```ts
const base = () => {
const router= new OpenAPIHono()
router.use(databaseMiddleware)...
13 Replies
GitHub
middleware/packages/swagger-ui at main · honojs/middleware
monorepo for Hono third-party middleware/helpers/wrappers - honojs/middleware
this is how I consume the factory method. so how can I add the swagger to the returned instance if the instance doesn't have
.openapi
on it?
by the way, you actually suggested creating the factory methods a while agome?
yes, it was a good solution.
probably its been a long time
oh, i think i remember now
let me try
i don't think that will work for swagger
it needs a stable reference for creating stuff
is there any other alternative that is not Postman that hono has integration
you can use the hono client thingy via monorepo
RPC - Hono
Web framework built on Web Standards for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Node.js, and others. Fast, but not only fast.
idk if you can the whole composition with builder for the client setup
I'm using RPC, but I need to provide API documentation for the security team, and swagger was the default because the company I work for uses c# as primary language for the backend and they expect swagger
idk if composing is good for this case then
ya, I will just import functions on every route that uses them
Solution
turns out you have to break it up and it works