ShogunPanda / fastify-openapi-docs

A simple plugin for Fastify that generates OpenAPI spec automatically.
ISC License
27 stars 5 forks source link

Not possible to set a Content-Type other than "application/json" #6

Closed davitykale closed 2 years ago

davitykale commented 2 years ago

I might be missing something, but it looks like application/json is hard-coded as the Content-Type for every endpoint. Is it possible to allow for customizing this?

ShogunPanda commented 2 years ago

It depends what you want to achieve. If you want your endpoint to return non application/json, you can use the $raw keyword as stated in the README. You can see an example of its usage here https://github.com/ShogunPanda/fastify-openapi-docs/blob/eed33e99c7331b2cf729377e89bfc5ebdfc9ee50/test/spec.test.ts#L492.

With that approach the endpoint will accept that MIME but you will lose the possibility to validate the data.

Or am I missing anything?

davitykale commented 2 years ago

@ShogunPanda does this work for the request as well? I want to to make a request to an endpoint with Content-Type: multipart/form-data and then have the response be JSON

davitykale commented 2 years ago

https://swagger.io/docs/specification/describing-request-body/multipart-requests/?sbsearch=Content%20Type

ShogunPanda commented 2 years ago

Released in v2.1.0

davitykale commented 2 years ago

Amazing! Thank you!