update samples

This commit is contained in:
William Cheng 2020-07-23 15:01:22 +08:00
parent 1bfd86a350
commit d1fe2e17f1

View File

@ -672,9 +672,17 @@ public class ApiClient {
} else {
// We let jersey handle the serialization
if (isBodyNullable) { // payload is nullable
entity = Entity.entity(obj == null ? "null" : obj, contentType);
if (obj instanceof String) {
entity = Entity.entity(obj == null ? "null" : "\"" + ((String)obj).replaceAll("\"", Matcher.quoteReplacement("\\\"")) + "\"", contentType);
} else {
entity = Entity.entity(obj == null ? "null" : obj, contentType);
}
} else {
entity = Entity.entity(obj == null ? "" : obj, contentType);
if (obj instanceof String) {
entity = Entity.entity(obj == null ? "" : "\"" + ((String)obj).replaceAll("\"", Matcher.quoteReplacement("\\\"")) + "\"", contentType);
} else {
entity = Entity.entity(obj == null ? "" : obj, contentType);
}
}
}
return entity;
@ -709,7 +717,7 @@ public class ApiClient {
if (isBodyNullable) {
return obj == null ? "null" : json.getMapper().writeValueAsString(obj);
} else {
return json.getMapper().writeValueAsString(obj);
return obj == null ? "" : json.getMapper().writeValueAsString(obj);
}
}
} catch (Exception ex) {