My NestJS server has an endpoint that accepts files and also additional form data For example I pass a file and a user_id of the file creator in the form.
NestJS Swagger needs to be told explicitly that body contains the file and that the endpoint consumes multipart/form-data
this is not documented in the NestJS docs https://docs.nestjs.com/openapi/types-and-parameters#types-and-parameters.
Luckily some bugs led to discussion about how to handle this use case
looking at these two discussions https://github.com/nestjs/swagger/issues/167 https://github.com/nestjs/swagger/issues/417 I was able to put together the following
I have added annotation using a DTO: the two critical parts are:
in the DTO add
in the controller add
this gets me a working endpoint
and this OpenAPI Json
...