I have to upload multiple file of type MultipartFile from swagger to test my api. Postman does allow to upload, however, same thing is not working in swagger.
Code for list of multipart file:
@ApiParam(name = "file", value = "Select the file to Upload", required = true, allowMultiple=true)
@RequestPart(value = "file", required = true) List<MultipartFile> file
working curl command for list of multipart file:
curl -X POST "http://localhost:8080/test" -H "accept: */*" -H "Content-Type: multipart/form-data" -F "[email protected];application/pdf;" -F "[email protected];application/pdf;" -F "jsonString={}"
Single multipart file works in swagger as well like this:
@ApiParam(name = "file", value = "Select the file to Upload", required = true, allowMultiple=true)
@RequestPart(value = "file", required = true) MultipartFile file
Dependency:
<!-- swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>