[Java][Spring] Fix URL-encoded form array binding
HM
6h ago+136+136+012345678901234567890123456789-30-30-01234567890123456789
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 --checkpassed.
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:
(For Windows users, please run the script in WSL)./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit
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.