Skip to content

[Bug][java-spring] Use Flux only for multipart-form-data file parameters with multiple file uploads #21561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

btpnlsl
Copy link
Contributor

@btpnlsl btpnlsl commented Jul 15, 2025

Closes #21559

This change fixes the parameter type used for multipart-form-data file uploads when generating code with the Java Spring OpenAPI generator with Spring WebFlux (reactive).

The current generator is using the parameter type of Flux<Part> for specs with single file uploads, and List<Flux<Part>> for specs with multiple file uploads. For more details see #21559

This PR changes the Java Spring templates to generating code with Part for single file uploads, or Flux<Part> for multi file uploads. A new unit test was added to SpringCodegenTest.java to test that the parameter type is correct for single & multi file upload parameters with Spring WebFlux.

There has been some recent prior work around multipart-form-data file uploads for non-reactive Spring servers, such as #21524, #21465

The prior PR to address multipart-form-data file uploads for reactive Spring was #6993

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Java Spring: @cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @banlevente (2022/02) @Zomzog (2022/09) @martin-mfg (2023/08)
Prior work on multipart-form-data file uploads for Java Spring: @wing328 @SidWagz @bit-factor

@wing328 wing328 changed the title Use Flux only for multipart-form-data file parameters with multiple f… Use Flux only for multipart-form-data file parameters with multiple file uploads Jul 17, 2025
@wing328
Copy link
Member

wing328 commented Jul 17, 2025

thanks for the pr

if no feedback/question from anyone, i'll merge it this weekend

@btpnlsl btpnlsl changed the title Use Flux only for multipart-form-data file parameters with multiple file uploads [Bug][java-spring] Use Flux only for multipart-form-data file parameters with multiple file uploads Jul 17, 2025
@btpnlsl
Copy link
Contributor Author

btpnlsl commented Jul 17, 2025

I think that there are some residual bugs for the non-reactive Spring case related to using @RequestPart vs @RequestParam (e.g. #21457)

@btpnlsl
Copy link
Contributor Author

btpnlsl commented Jul 28, 2025

@wing328 did you need anything else for this PR before merging?

@wing328 wing328 merged commit a60d3d4 into OpenAPITools:master Jul 28, 2025
63 checks passed
@wing328
Copy link
Member

wing328 commented Jul 28, 2025

Just merged it. Sorry for the delay.

Thanks again for the contribution

@wing328 wing328 added this to the 7.15.0 milestone Aug 9, 2025
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][Java-Spring] Wrong parameter type for multipart-form-data, multipe file upload when using java-spring with reactive
3 participants