-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hono/combine
compatibility
#21
Comments
This is a good idea, but implementing it poses significant challenges without relying on some form of global storage. Even if we attempt to create a version of The main issue lies in how we generate the OpenAPI specs. The current approach relies on static generation, which doesn’t account for dynamic runtime conditions like those defined in Moreover, even if we manage to address this, there’s a high risk the final generated spec won’t comply with OpenAPI standards, given the complexities of conditional middleware. That said, I’d love to explore this further if you have a concrete proposal or workaround in mind. Feel free to submit a PR with your idea |
I'm having this exact issue, I want to create a higher level opinionated abstraction. Would love to see this solved. Thanks for this great library EDIT: I figured for |
Can you share a use case or an example of how you wanna use it? |
Sure, so I created Now, when I discovered this library (as recommended by Hono docs) I wanted to superimpose the openapi part over the accepts and returns middleware without the ceremony of defining the status code (always 200 unless errors), return type (always json) and validation parts, I liked the existing API surface. I tried wrapping the openapi logic in my own middleware but, reading the code, I saw it hooks into the middleware via a I ended up using a middleware factory function which simply returns the openapi validator with a hook to parse the body and some other logic, and the returns middleware is just a simplified wrapper over the defineRoute without the ceremony. |
It would be really nice if you could somehow use
hono/combine
with the hono-openapi middleware. In my case I want to build an opinionated high-level abstraction to reduce the boilerplate on each route.Currently this does not work because the OpenAPI schema is stored to the prototype of the middleware function and wrapping it causes this information to be lost.
I suspect the easiest way to support this would be for
hono-openapi
to expose it's ownhono-openapi/combine
module because I think alternatives would require the OpenAPI schema's to be stored somewhere else and I am not sure if any other options exists that would be viable.Thanks for this awesome project!
The text was updated successfully, but these errors were encountered: