-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] [Java Resttemplate] Incorrect handling of free form query parameters #8352
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
Hello, To explain my problem a little : "/documents/search": {
"get": {
"operationId": "searchByParameters",
"parameters": [
{
"name": "family",
"in": "query",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "metadata",
"in": "query",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"style": "form",
"explode": true
}
] The generated java code is :
And when I test my code with a unit test : @Test
void testSearchByParameters() throws Exception {
final Map<String, String> params = new HashMap<>();
params.put("id", "400824298");
params.put("label", "Description");
StepVerifier.create(documentsApi.searchByParameters("myFamily", params))
.expectNextMatches(result -> result instanceof Document && result.getMetaData()
.equals(params))
.verifyComplete();
} I get the error below : And with the fix, the call is done perfectly with my list of exploded query params : Hope this help you to fix it. |
…of free-form query parameters with Java
Thanks for the fix by @RomainPruvostMHH @gspatace, can you please give it a try with the latest master? |
@wing328 it works as expected. |
Description:
Currently, when using free form query parameters, the URI is not built correctly.
Steps to reproduce:
Input spec file:
Command to generate client files:
java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i spec.yml -o work -g java --library resttemplate
Client code ( usage of generated API ):
Expected result of URI built for the endpoint:
http://localhost/some/endpoint?fixed=fixedValue&this=first&that=second&other=third
Actual result:
http://localhost/some/endpoint?fixed=fixedValue&free-form=%7Bthat%3Dsecond%2C+other%3Dthird%2C+this%3Dfirst%7D
Tested with master as of today.
I've added a patch that addresses this, I'll open a PR soon, too.
free-form-params.txt
The text was updated successfully, but these errors were encountered: