cloudflare / chanfana

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

Response body validation #147

Closed marceloverdijk closed 2 weeks ago

marceloverdijk commented 2 months ago

Similar as https://cloudflare.github.io/itty-router-openapi/user-guide/request-body/ it would be great to have Response body validation.

Maybe in a different manner as this is maybe less suited for Runtime errors, but instead for compile time.

Rationale: 1) make sure responses follow the defined openapi contact. 2) make sure that additionally fetched fields from eg database query are not accidentally included in the response; eg think about any secret field in User table.

marceloverdijk commented 2 weeks ago

See https://github.com/cloudflare/chanfana/issues/159 for more details using Chanfana.