fastify / fastify-swagger

Swagger documentation generator for Fastify
MIT License
915 stars 201 forks source link

how to add binary file as request body? #698

Closed gusparr28 closed 1 year ago

gusparr28 commented 1 year ago

Prerequisites

Issue

No response

gusparr28 commented 1 year ago

I have an endpoint that receives binary file in request body. How to add that spec to Fastify Swagger? I've been through the docs and different issues and haven't found a clear solution. Appreciated. Thanks

Uzlopak commented 1 year ago

https://swagger.io/docs/specification/describing-request-body/file-upload/

climba03003 commented 1 year ago

https://swagger.io/docs/specification/describing-request-body/file-upload/

Pasting Swagger link do not helps in any case. We transform JSON Schema to API Docs which require users to pass proper JSON Schema.

If you need to use formdata. { type: 'string', format: 'binary' } would do the trick, but you should remove the validator. Since ajv DO NOT support binary.