Description
The reactive (WebFlux) server interface template (templateReactive.ftlh) has no handling for multipart/form-data request bodies. It wraps the request body in Mono<...> / Flux<...> with @Valid @RequestBody and references the wrapper DTO, so a multipart upload:
- has no
@RequestPart binding and no consumes declaration, and
- would use the wrapper DTO /
MultipartFile, which is a Servlet type not supported by WebFlux annotated controllers.
This is the reactive counterpart of the annotated-controller multipart issue (#388).
Steps to reproduce
Generate a reactive API (reactive: true) from a spec with a multipart/form-data body containing a file (type: string, format: binary) and a file array.
Expected result
Each part exposed as @RequestPart, files typed with the WebFlux FilePart API, plus a consumes declaration:
@RequestMapping(method = RequestMethod.POST, value = "/upload",
produces = {"application/json"},
consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
default ResponseEntity<Void> uploadMultipart(
@RequestPart(value = "someFile", required = false) FilePart someFile,
@RequestPart(value = "someFiles", required = false) Flux<FilePart> someFiles,
@RequestPart(value = "someString", required = false) String someString,
@ApiIgnore final ServerWebExchange exchange) { ... }
Root cause
templateReactive.ftlh never branches on request.isFormData; both signature variants (with/without securities) always emit @RequestBody wrapped in Mono/Flux.
Environment
- OpenAPI code generator (
multiapi-engine), reactive server interface template.
- Reproduced on
main.
Description
The reactive (WebFlux) server interface template (
templateReactive.ftlh) has no handling formultipart/form-datarequest bodies. It wraps the request body inMono<...>/Flux<...>with@Valid @RequestBodyand references the wrapper DTO, so a multipart upload:@RequestPartbinding and noconsumesdeclaration, andMultipartFile, which is a Servlet type not supported by WebFlux annotated controllers.This is the reactive counterpart of the annotated-controller multipart issue (#388).
Steps to reproduce
Generate a reactive API (
reactive: true) from a spec with amultipart/form-databody containing a file (type: string, format: binary) and a file array.Expected result
Each part exposed as
@RequestPart, files typed with the WebFluxFilePartAPI, plus aconsumesdeclaration:Root cause
templateReactive.ftlhnever branches onrequest.isFormData; both signature variants (with/withoutsecurities) always emit@RequestBodywrapped inMono/Flux.Environment
multiapi-engine), reactive server interface template.main.