Skip to content

Fix - pathParam conversion from enum to string - #2011

Merged
poojah-adyen merged 1 commit into
mainfrom
fix-param-map-enum-value
Jul 21, 2026
Merged

poojah-adyen merged 1 commit into
mainfrom
fix-param-map-enum-value

Conversation

@poojah-adyen

@poojah-adyen poojah-adyen commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Description
Fix template to convert non-String path parameters (e.g. enums) with .toString(), preventing compile errors like the new CampaignStatusTransition status path param in DonationCampaignsApi.

Error

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.15.0:compile (default-compile) on project adyen-java-api-library: Compilation failure
Error:  /home/runner/work/adyen-java-api-library/adyen-java-api-library/src/main/java/com/adyen/service/management/DonationCampaignsApi.java:[403,30] incompatible types: com.adyen.model.management.CampaignStatusTransition cannot be converted to java.lang.String

Git hub pipeline - https://github.com/Adyen/adyen-java-api-library/actions/runs/29820136294/job/88600760813?pr=2004

@poojah-adyen
poojah-adyen requested a review from a team as a code owner July 20, 2026 08:28
@poojah-adyen poojah-adyen self-assigned this Jul 20, 2026
@poojah-adyen poojah-adyen added the Fix Indicates a bug fix label Jul 20, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request updates the Jersey 3 API template to convert non-string path parameters to strings. The reviewer correctly identified that calling .toString() directly on primitive types will result in compilation errors in Java, and suggested using String.valueOf() as a safer alternative.

throw new IllegalArgumentException("Please provide the {{{paramName}}} path parameter");
}
pathParams.put("{{baseName}}", {{{paramName}}});
pathParams.put("{{baseName}}", {{{paramName}}}{{^isString}}.toString(){{/isString}});

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.

medium

If a path parameter is a primitive type (such as int, long, or boolean), calling .toString() directly on it will cause a compilation error in Java because primitive types do not have methods. Using String.valueOf() is a safer and more robust approach because it handles both primitive types and object types (like enums or custom classes) seamlessly.

        pathParams.put("{{baseName}}", {{#isString}}{{{paramName}}}{{/isString}}{{^isString}}String.valueOf({{{paramName}}}){{/isString}});

@sonarqubecloud

Copy link
Copy Markdown

@poojah-adyen
poojah-adyen enabled auto-merge July 20, 2026 13:14
@jeandersonbc

jeandersonbc commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

ok, the mystery is solved: I was pretty sure that we handled these cases already. However, we were handling query params, not path parameters. I wonder whether affected code shouldn't be a query param instead but that's out of scope (at least for now). Adding this example (of query param) for reference: https://github.com/Adyen/adyen-java-api-library/blob/main/src/main/java/com/adyen/service/balanceplatform/TransferLimitsBalanceAccountLevelApi.java#L334-L344

@poojah-adyen
poojah-adyen added this pull request to the merge queue Jul 21, 2026
Merged via the queue into main with commit eebe797 Jul 21, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fix Indicates a bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants