cloudflare / chanfana

OpenAPI 3 and 3.1 schema generator and validator for Hono, itty-router and more!
https://chanfana.pages.dev
MIT License
275 stars 38 forks source link

lacking type safety in the openapi route object #110

Open moodysalem opened 7 months ago

moodysalem commented 7 months ago

the static schema does not match the the request type, and does not have typing on the handle parameters

makes this library really hard to use

it's also not clear how to describe the parameters!

and there are multiple places where params can be defined!

image

need to make better use of typescript for this to be nice to use

i would also recommend the schema not being static so you don't have to compute the schema and construct everything until the route is hit

patryk-smc commented 5 months ago

This lib would be 100x better if those were typed. Happy to make PR if interested @G4brym

G4brym commented 5 months ago

This is a known issue, i just didn't got any time yet to get to it The issue with migrating from the static schema, is that we want to keep backwards compatibility with people using the static version

i would also recommend the schema not being static so you don't have to compute the schema and construct everything until the route is hit

I still need to think about this because, if we move the schema compute to only when the route is hit, we still need a way to compute all route schemas when someone hits openapi.json path

@patryk-smc feel free to open a PR 😄 if you decide to tackle both issues, please split into 2 pr's