Skip to content

[Java][Spring] Fix URL-encoded form array binding - #25436

Open
hmooko wants to merge 2 commits into
OpenAPITools:masterfrom
hmooko:fix/spring-form-list-14866
Open

hmooko wants to merge 2 commits into
OpenAPITools:masterfrom
hmooko:fix/spring-form-list-14866

Conversation

@hmooko

@hmooko hmooko commented Oct 27, 2026 •

Copy link
Copy Markdown

URL-encoded form arrays were generated with @RequestPart, so Spring MVC could receive null even when repeated form fields were supplied. Generate @RequestParam for non-multipart arrays and retain @RequestPart for multipart arrays.

Add a POST generation regression test for required and optional string arrays, and MockMvc binding tests using the existing sample endpoint. Refresh the affected annotation in 29 existing generated samples without adding endpoints or changing shared sample specifications.

Closes #14866

Validation:

  • ./mvnw -B -pl modules/openapi-generator -am -Dtest=SpringCodegenTest -Dsurefire.failIfNoSpecifiedTests=false test — 487 tests passed.
  • ./mvnw -B -f samples/server/petstore/springboot/pom.xml test — 5 tests passed, including 2 MockMvc tests.
  • The new generation and binding regression tests fail with the original annotation and pass with the fix. The binding regression reproduces a 200 response with a null list under @RequestPart.
  • Compared original and fixed template output for the affected sample configurations and retained only the annotation changes. git diff --check passed.

Full PR checklist validation also completed successfully:

  • ./mvnw -B clean package — all 8 reactor modules built successfully; 5,678 tests reported, with 14 skipped and no failures or errors.
  • ./bin/generate-samples.sh ./bin/configs/*.yaml — all 832 sample configurations generated successfully. Some generators logged non-fatal unsupported-feature/example-generation messages; the batch completed successfully and produced no working-tree changes.
  • ./bin/utils/export_docs_generators.sh — documentation exported for all 172 generators, with no errors or working-tree changes.

PR checklist

  • Read the contribution guidelines.
  • 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.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@hmooko

hmooko commented Oct 27, 2026

Copy link
Copy Markdown
Author

@MelleD Could you please review this Java Spring fix for #14866? It uses @RequestParam for URL-encoded form arrays while preserving @RequestPart for multipart arrays. Generation and MockMvc regression tests pass, the full build and sample/document regeneration are complete, and all four CircleCI checks passed. Thank you!

@hmooko
hmooko marked this pull request as ready for review October 27, 2026 02:09

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 33 files

View guided diff | Re-trigger cubic

This branch has not been deployed

No deployments
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] List<String> not bound correctly in x-www-form-urlencoded POST requests (JavaSpring generator)

1 participant