Skip to content

Generate @RequestPart parameters for reactive multipart/form-data controllers - #392

Merged
jemacineiras merged 2 commits into
sngular:mainfrom
joseegman-idoneea:feat/multipart-reactive-requestpart
Jul 31, 2026
Merged

Generate @RequestPart parameters for reactive multipart/form-data controllers#392
jemacineiras merged 2 commits into
sngular:mainfrom
joseegman-idoneea:feat/multipart-reactive-requestpart

Conversation

@joseegman-idoneea

@joseegman-idoneea joseegman-idoneea commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

What

Adds multipart/form-data support to the reactive (WebFlux) server interface template. Closes #391.

Each form-data part is exposed as its own @RequestPart parameter using the WebFlux multipart API, and the endpoint declares consumes = MediaType.MULTIPART_FORM_DATA_VALUE.

Why

templateReactive.ftlh never branched on request.isFormData — it always wrapped the body in Mono/Flux with @Valid @RequestBody, so reactive multipart uploads had no @RequestPart binding, no consumes, and would rely on the Servlet-only MultipartFile type (unsupported in WebFlux).

Change

  • templateReactive.ftlh: for form-data requests, emit one @RequestPart per schema property via a small FreeMarker macro shared by both signature variants (with/without securities). File parts use the WebFlux types — single file → FilePart, file array → Flux<FilePart> — non-file parts keep their declared type. Adds consumes, imports FilePart only when a file part exists, and stops importing the (no longer generated) wrapper model.

Generated output

@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) { ... }

Test

  • New testReactiveFormDataMultipart fixture + golden UploadApi.java.
  • Full engine suite green: Tests run: 119, Failures: 0, Errors: 0.

Version

Bumps 6.6.26.6.3 across engine, Maven plugin and Gradle plugin.

Note

Builds on #389 (annotated @RequestPart multipart controllers, now merged), which added the shared "don't generate a wrapper model for form-data" change. Rebased onto main, so this PR contains only its own two commits.

🤖 Generated with Claude Code

@codacy-production

codacy-production Bot commented Jul 31, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 72 complexity · 3 duplication

Metric Results
Complexity 72
Duplication 3

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

joseegarcia and others added 2 commits July 31, 2026 10:49
…trollers

templateReactive.ftlh had no multipart branch: it always wrapped the request
body in Mono/Flux with @Valid @RequestBody, so reactive multipart uploads
lacked @RequestPart binding and a consumes declaration.

Now each form-data part is exposed as its own @RequestPart parameter using
the WebFlux multipart API (single file -> FilePart, file array ->
Flux<FilePart>, non-file parts keep their declared type), and the
@RequestMapping declares consumes = MediaType.MULTIPART_FORM_DATA_VALUE.
FilePart is imported only when a file part is present, and the (no longer
generated) wrapper model is not imported.

Adds a testReactiveFormDataMultipart fixture and golden interface.

Fixes sngular#391

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@joseegman-idoneea
joseegman-idoneea force-pushed the feat/multipart-reactive-requestpart branch from ccbe20c to b6bc584 Compare July 31, 2026 08:50
@jemacineiras
jemacineiras merged commit 23082aa into sngular:main Jul 31, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants