[Java][OkHttp-Gson] fix: free form query parameters for okhttp-gson (#19226)

This commit is contained in:
llendi
2024-08-15 11:02:59 +02:00
committed by GitHub
parent 05c10934ce
commit 38ebf0bb4e
20 changed files with 561 additions and 1 deletions

View File

@@ -829,6 +829,30 @@ public class ApiClient {
return params;
}
/**
* 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(Object value) {
List<Pair> params = new ArrayList<>();
// preconditions
if (value == null || !(value instanceof Map )) {
return params;
}
final Map<String, Object> valuesMap = (Map<String, Object>) value;
for (Map.Entry<String, Object> entry : valuesMap.entrySet()) {
params.add(new Pair(entry.getKey(), parameterToString(entry.getValue())));
}
return params;
}
/**
* Formats the specified collection path parameter to a string value.
*