@hono/zod-openapi generates :param instead of {param} β breaks openapi-fetch compatibility
I'm using @hono/zod-openapi to generate an OpenAPI spec for my Hono backend, but it outputs paths like /channels/:handle instead of the OpenAPI standard /channels/{handle}. This breaks compatibility with openapi-fetch, which expects {param} syntax.
Is there a way to configure @hono/zod-openapi to output {param} format instead of :param? Or is post-processing the generated OpenAPI JSON the only option?
Appreciate any suggestions π
8 Replies
I actually don't think it even understands path params
It looks like it takes the path string as is
I mean, it doesn't have to, since you provide it a schema describing them
So yeah, modifying the schema in a middleware would probably be the easiest solution to this
You could maybe cache the result in-memory?
Itβs odd that the generated OpenAPI doc doesnβt adhere to the specs by default β having to manually fix it would be quite a hassle.
as I said, I don't think it "generates" the path parameter in the url
it leaves it as-is
you're meant to specify the openapi-compatible path in the spec: https://hono.dev/examples/zod-openapi
createRoute
takes a path
paramthat's ass
π€·
hono-openapi
might do it automaticallyit does
Oops, my mistake! I can just switch :param to {param} and it still works. The documentation notes that {param} only fails when using app.route, not createRoute.
