routing-controllers-openapi icon indicating copy to clipboard operation
routing-controllers-openapi copied to clipboard

Can 'multipart/form-data' be added to the output OpenAPI spec, for the @UploadedFiles decorator?

Open sixman9 opened this issue 6 years ago • 3 comments
trafficstars

I'm new to Typescript/Javascript (Java Dev), but I'm trying to keep my development as DRY as possible.

I already know that my Express code works and can do 'multipart/form-data' file uploads, via the '@UploadedFiles' decorator, however, I'd like to see that reflected in the OpenAPI spec, output by your project, so any client code I generate will be aware of it (i.e. 'multipart/form-data').

How can I achieve the addition of 'multipart/form-data' programmatically, using routing-controllers-openapi/routing-controllers?

See https://swagger.io/docs/specification/describing-request-body/multipart-requests

sixman9 avatar Mar 03 '19 10:03 sixman9

Hi, handling @UploadedFile/ @UploadedFiles would indeed make a great addition, thanks for the suggestion! We'd probably need to extend the getRequestBody function to check for said decorators (route.params.filter(d => ['file', 'files'].includes(d.type)) and merge the multipart/form-data block you linked into the return object (along the existing application/json block).

Would be happy to merge in a PR if anyone gets around implementing this!

epiphone avatar Mar 04 '19 08:03 epiphone

Hello @epiphone , how can I achieve additional 'multiple data / form data' using the router-controller-openapi / routing controller? Could you example me Thank you

Brian-NgH777 avatar Aug 12 '19 17:08 Brian-NgH777

Any progress on this?

nicholasbraun avatar Apr 29 '21 08:04 nicholasbraun