Skip to content

[Kotlin][Spring] use WebFlux Part types for reactive multipart files#24296

Draft
wingwogus wants to merge 1 commit into
OpenAPITools:masterfrom
wingwogus:fix/kotlin-spring-reactive-multipart-21548
Draft

[Kotlin][Spring] use WebFlux Part types for reactive multipart files#24296
wingwogus wants to merge 1 commit into
OpenAPITools:masterfrom
wingwogus:fix/kotlin-spring-reactive-multipart-21548

Conversation

@wingwogus

@wingwogus wingwogus commented Jul 14, 2026

Copy link
Copy Markdown

Fixes #21548.

Summary

  • Generate WebFlux multipart file parameters as org.springframework.http.codec.multipart.Part for reactive Kotlin Spring Boot servers.
  • Generate reactive file arrays as reactor.core.publisher.Flux<Part>.
  • Preserve the existing MultipartFile / Array<MultipartFile> output for blocking Spring Boot and reactive declarative HTTP interfaces.
  • Preserve nullability and all non-file multipart parameter rendering.

Implementation notes

A private derived template flag is enabled only for reactive=true with the spring-boot library. The existing optionalDataType.mustache file branch uses that flag, so this remains a narrow type-system correction rather than a new public generator option or a broad template split.

The two checked-in reactive Kotlin Spring samples were regenerated. Their intended deltas are limited to the multipart parameter type in the controller, service, service implementation, and generated API test.

@dr4ke616 @e5l, this touches the Kotlin Spring Boot reactive server output.

Verification

  • Full KotlinSpringServerCodegenTest: 236 tests, 0 failures/errors/skips.
  • Regenerated kotlin-spring-boot-reactive and kotlin-spring-boot-reactive-without-flow samples.
  • Compiled both sample main source sets on local JDK 21 with Gradle 8.5.
  • Compared sample test compilation with clean base copies: the multipart mismatch is removed and no new error is introduced; unrelated pre-existing stale errors remain in both base and modified copies.
  • checkstyle:check passed for modules/openapi-generator.
  • git diff --check passed.

The official JDK 11 / Gradle 7.6.4 sample matrix was not available locally; CI is expected to cover it.

PR checklist

  • Read the contribution guidelines.
  • Run the full repository build/sample/doc regeneration commands from the PR template. The two affected samples, full generator test class, sample compilation, and checkstyle were run as documented above.
  • Mention the relevant technical committee members.

Summary by cubic

Use WebFlux Part for reactive multipart parameters in Kotlin Spring Boot servers, with arrays as Flux<Part>, to match the reactive request pipeline. Blocking Spring Boot and declarative HTTP interfaces keep MultipartFile. Fixes #21548.

  • Bug Fixes

    • Generate org.springframework.http.codec.multipart.Part and reactor.core.publisher.Flux<Part> when reactive=true with the spring-boot library.
    • Keep nullability and all non-file form fields unchanged; no changes for blocking or spring-declarative-http-interface outputs.
    • Added focused tests and regenerated Kotlin reactive samples.
  • Migration

    • After regenerating a reactive Kotlin Spring Boot server, update handlers to accept Part (and Flux<Part> for arrays) instead of MultipartFile/Array<MultipartFile>.

Written for commit 805becf. Summary will update on new commits.

Review in cubic

Kotlin Spring reactive server endpoints must accept WebFlux Part values,
including Flux for file arrays, so generated controllers and service
surfaces remain compatible with the reactive request pipeline. Derive the
template condition inside the server generator and preserve the existing
MVC and declarative-interface output.

Constraint: WebFlux server generation requires Part and Flux<Part>; blocking and declarative HTTP interface output must retain MultipartFile.
Rejected: Rewrite broader multipart templates | would churn unrelated model, form-field, and array rendering.
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep reactiveMultipart derived from reactive Spring Boot server mode; do not key this shared partial on reactive alone.
Tested: Focused multipart tests; KotlinSpringServerCodegenTest 236/0/0/0; checkstyle; both sample main source sets compile; base/current generated-output differential.
Not-tested: Official JDK 11 and Gradle 7.6.4 sample CI matrix; baseline-stale unrelated sample test-source errors remain.
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.

[BUG][Kotlin-Spring] Wrong parameter type for multipart-form-data file upload when using kotlin-spring with reactive

1 participant