mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-17 08:31:23 +00:00
Fix query parameters encoding in Java apache-httpclient (#14195)
* fix query parameters encoding in java apache-httpclient * rearrange tests * add new files
This commit is contained in:
@@ -596,9 +596,11 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
List<Pair> params = new ArrayList<Pair>();
|
||||
|
||||
// preconditions
|
||||
if (name == null || name.isEmpty() || value == null || value instanceof Collection) return params;
|
||||
if (name == null || name.isEmpty() || value == null || value instanceof Collection) {
|
||||
return params;
|
||||
}
|
||||
|
||||
params.add(new Pair(name, parameterToString(value)));
|
||||
params.add(new Pair(name, escapeString(parameterToString(value))));
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -845,6 +847,10 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
if (mimeType == null || isJsonMime(mimeType)) {
|
||||
// Assume json if no mime type
|
||||
return objectMapper.readValue(entity.getContent(), valueType);
|
||||
} else if ("text/plain".equalsIgnoreCase(mimeType)) {
|
||||
// convert input stream to string
|
||||
java.util.Scanner s = new java.util.Scanner(entity.getContent()).useDelimiter("\\A");
|
||||
return (T) (s.hasNext() ? s.next() : "");
|
||||
} else {
|
||||
throw new ApiException(
|
||||
"Deserialization for content type '" + mimeType + "' not supported for type '" + valueType + "'",
|
||||
@@ -933,7 +939,8 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
url.append("&");
|
||||
}
|
||||
String value = parameterToString(param.getValue());
|
||||
url.append(escapeString(param.getName())).append("=").append(escapeString(value));
|
||||
// query parameter value already escaped as part of parameterToPair
|
||||
url.append(escapeString(param.getName())).append("=").append(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user