OpenAPITools / OpenAPITools/openapi-generator
[BUG][Java][resttemplate] Query param values not encoded anymore
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
We are currently on OpenApi generator 5.4.0. Due to issues generating polymorphic classes we tried to upgrade to 6.0.1.
We are using a queryparam with a callback url of a string type currently.
In version 5.4.0 the ApiClient had this line:
if (value != null) {
String templatizedKey = encodedName + valueItemCounter++;
final String encodedValue = URLEncoder.encode(value.toString(), "UTF-8");
uriParams.put(templatizedKey, encodedValue);
queryBuilder.append('=').append("{").append(templatizedKey).append("}");
}
In 6.0.1 the code changed to:
if (value != null) {
String templatizedKey = encodedName + valueItemCounter++;
uriParams.put(templatizedKey, value.toString());
queryBuilder.append('=').append("{").append(templatizedKey).append("}");
}
Without the encoding somehow our url changed from:
/some-mock/api/1.0/endpoint/method?callbackUrl=http:/**/**other-service/servicename/api/1.0/endpoint/method
to
/some-mock/api/1.0/endpoint/method?callbackUrl=http:/other-service/servicename/api/1.0/endpoint/method
This is a problem because i don't think http:/ would be a valid url. Also it breaks our wiremock expects in integration tests.
openapi-generator version
6.0.1.
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/11921
https://github.com/OpenAPITools/openapi-generator/pull/11922
It seems mentioned PR and issue changed the behavior, but i am unsure as to how i should restore our application with this.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the Java RestTemplate ApiClient query-parameter handling in OpenAPI Generator 5.4.0 and 6.0.1, alongside issue 11921 and PR 11922. Restore the expected encoding behavior for callback URL query values and verify that generated URLs retain the encoded value used by the integration expectations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100