Closed
Description
For an endpoint using Spring WebFlux to upload a file, the Swagger UI documentation is not generated properly. It doesn't allow to choose a file and send it as a multipart request:
This is the endpoint that has a FilePart
parameter for reactive file upload:
@Operation(summary = "Parse Resume")
@PostMapping(value = "/parse-resume", produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = { MediaType.MULTIPART_FORM_DATA_VALUE })
@ApiResponses({
@ApiResponse(responseCode = "400", description = "Invalid input")
})
public Mono<ResumeDTO> parse(
@RequestPart(name = "resumeFile")
@Parameter(description = "Resume file to be parsed", content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE)) FilePart resumeFile) {
...
}
The generated apidoc for the endpoint looks as following:
"/api/parse-resume":{
"post":{
"tags":[
"Resume"
],
"summary":"Parse Resume",
"operationId":"parse",
"requestBody":{
"description":"Resume file to be parsed",
"content":{
"multipart/form-data":{
"schema":{
"$ref":"#/components/schemas/FilePart"
}
}
},
"required":false
},
...
}