cloudflare / chanfana

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

Allow custom Content-Types as responses #48

Closed cubercsl closed 1 year ago

cubercsl commented 1 year ago

As OpenAPI Specification described here, the content type of the response is customizable.

https://github.com/cloudflare/itty-router-openapi/blob/c9f364a0b1d276b46edca2c04ff14a3a79b8172f/src/route.ts#L34-L40

https://github.com/cloudflare/itty-router-openapi/blob/c9f364a0b1d276b46edca2c04ff14a3a79b8172f/src/parameters.ts#L539-L558

But there is nowhere in the code to define the Content-Type of the response, so the generated document will always be application/json.

G4brym commented 1 year ago

Hey @cubercsl this bug is something we found recently, and we will be solving it very soon Thanks for reporting it, I will keep this issue updated here

agotfredsen82 commented 1 year ago

yes please update this I'm stuck with a project because of this little thing :-) please please fix asap.

G4brym commented 1 year ago

A pr with this is already open #52 I'm testing it, and a new release will be open tomorrow

G4brym commented 1 year ago

Try out the new content type option on the latest release (v0.1.4) Here are some examples on how to use it https://github.com/cloudflare/itty-router-openapi#9-custom-responses-formats