fix: Remove extra commas when generating with cookies with Retrofit2

Merged
WG
5mo ago
+106-0

Fixes https://github.com/OpenAPITools/openapi-generator/issues/2689 using the strategy described here.

Added a unit test to verify the logic.

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.

Pinging the Java committee members as per the PR checklist: @sreeshas @lukoyanov @jeff9finger @Zomzog @martin-mfg (half, since the group is so big).


Summary by cubic

Prevents dangling commas in generated retrofit2 interfaces when operations include cookie parameters by omitting cookie params from method signatures. Fixes #2689 and adds tests to ensure generated code compiles.

  • Bug Fixes
    • In JavaClientCodegen (for retrofit2), remove cookie parameters from operation.allParams before rendering to avoid trailing/leading commas and invalid Javadoc.
    • Added testRetrofit2CookieParamsOmittedFromSignature and retrofit2-cookie-params.yaml to cover cookie-first/last/only cases and validate Java parsing.