[Java][jersey2/jersey3] Fix serialization of array path parameters
Closes #24985
Array path parameters were serialized with Collection.toString(), producing "[a, b, c]" in the URL. Add ApiClient.collectionPathParameterToString, which escapes each item individually and joins them with the delimiter for the parameter's collection format (csv by default).
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.
@bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608 @martin-mfg @KannaKim
Summary by cubic
Fixes Java jersey2/jersey3 clients serializing array path parameters as [a, b, c] (from Collection.toString()) instead of the collection format's delimiter. Adds collectionPathParameterToString to ApiClient, which escapes each item individually and joins them with the correct delimiter; multi falls back to csv since it isn't valid for path parameters.
- Preserves the delimiter before leading empty or null items (e.g.
["", "b"]becomes",b"). - Updates generated samples and adds runtime tests for
collectionPathParameterToStringplus a codegen test using a new array path parameter spec.