I'm working on a Spring boot application which has a controller to help upload Multipart
files:
@PostMapping("/files")
public ResponseEntity<?> uploadFiles(
@RequestParam("file") MultipartFile[] file, String comment)
throws IOException, ExecutionException, InterruptedException {
log.debug("Total files to store: {}", file.length);
log.debug("comment: {}", comment);
fileService.storeFile(Arrays.asList(file), comment);
return ResponseEntity.ok(environment.getProperty("file.upload.success"));
}
Problem: Somehow OpenDocAPI (swagger) doesn't understand this payload as file.
It shows this field as String
if I mention @RequestParam("file") MultipartFile file
or String[]
if I use array of MultipartFiles.
My Spring boot parent:
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.1</version>
The spring doc openapi dependency:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.9</version>
</dependency>
The swagger page:
The result page when I click on Try it out:
The Execute button doesn't work
Any idea what am I missing in the controller?
PS - I tried with mentioning:
@PostMapping(value = "/files", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
But still OpenAPI would only treat it as String
.