Skip to content

Reactive (WebFlux) controllers have no multipart/form-data handling #391

Description

@joseegman-idoneea

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:

  1. has no @RequestPart binding and no consumes declaration, and
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions