Skip to content

Commit

Permalink
[Java][OkHttp-Gson] fix: free form query parameters for okhttp-gson
Browse files Browse the repository at this point in the history
  • Loading branch information
llendi committed Jul 23, 2024
1 parent 6ad5864 commit c6170f1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,28 @@ public class ApiClient {
}
{{/dynamicOperations}}
/**
* Formats the specified free-form query parameters to a list of {@code Pair} objects.
*
* @param value The free-form query parameters.
* @return A list of {@code Pair} objects.
*/
public List<Pair> freeFormParameterToPairs(Map<String, Object> value) {
List<Pair> params = new ArrayList<>();
// preconditions
if (value == null || value.isEmpty()) {
return params;
}
for (Map.Entry<String, Object> entry : value.entrySet()) {
params.add(new Pair(entry.getKey(), parameterToString(entry.getValue())));
}
return params;
}
/**
* Formats the specified collection path parameter to a string value.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public class {{classname}} {
{{^dynamicOperations}}
{{#queryParams}}
if ({{paramName}} != null) {
{{#collectionFormat}}localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("{{{.}}}", {{/collectionFormat}}{{^collectionFormat}}localVarQueryParams.addAll(localVarApiClient.parameterToPair({{/collectionFormat}}"{{baseName}}", {{paramName}}));
{{#collectionFormat}}localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("{{{.}}}", {{/collectionFormat}}{{^collectionFormat}}{{#isFreeFormObject}}localVarQueryParams.addAll(localVarApiClient.freeFormParameterToPairs({{paramName}}));{{/isFreeFormObject}}{{^isFreeFormObject}}localVarQueryParams.addAll(localVarApiClient.parameterToPair("{{baseName}}", {{paramName}}));{{/isFreeFormObject}}{{/collectionFormat}}
}

{{/queryParams}}
Expand Down

0 comments on commit c6170f1

Please sign in to comment.