If an API accept query parameter and parameter contains unsafe symbol, such as "&" sign, in the RestTemplate-based Java client, it is not encoded. When the request is sent as it is to the server side, it prevents the server from parsing the parameter properly.
3.0.0
https://github.com/OpenAPITools/openapi-generator/blob/v3.0.0/bin/java-petstore-resttemplate.sh
the line of code in question is at https://github.com/OpenAPITools/openapi-generator/blob/9c82520637b9cd4415046e78ddb13dec84e89509/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ApiClient.java#L518
the parameter string are put into UriComponentsBuilder as it is
It seems other flavour of Java clients, such as "okhttp-gson", is doing "escaping" while building the request, at https://github.com/OpenAPITools/openapi-generator/blob/9c82520637b9cd4415046e78ddb13dec84e89509/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java#L1037
we need to introduce this sanitisation in RestTemplate-based client
@simingweng thanks for reporting the issue with the details. May I know if you've time to contribute a fix?
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/ApiClient.mustache#L530 is a good starting point and I agree with you we should reuse similar technique in other Java clients.
sure, I can work on this.
Could this issue be closed?
Yes, I think so, the fix is already in 3.0.1 release.
Most helpful comment
sure, I can work on this.