[Java][okhttp-gson] Support text/plain body (#10885)

* support serialize RequestBody with contentType text/plain

* add Serialize test

* update test comment
This commit is contained in:
Kevin Chen
2021-11-26 01:04:19 -06:00
committed by GitHub
parent 06faa289bd
commit 3d92df5a41
6 changed files with 28 additions and 0 deletions

View File

@@ -972,6 +972,8 @@ public class ApiClient {
} else if (obj instanceof File) {
// File body parameter support.
return RequestBody.create((File) obj, MediaType.parse(contentType));
} else if ("text/plain".equals(contentType) && obj instanceof String) {
return RequestBody.create((String) obj, MediaType.parse(contentType));
} else if (isJsonMime(contentType)) {
String content;
if (obj != null) {