forked from loafle/openapi-generator-original
resolve java okhttp issue due to merge conflicts
This commit is contained in:
parent
ef40bdb7b0
commit
f1e237f76f
@ -73,6 +73,12 @@ public class ApiClient {
|
|||||||
*/
|
*/
|
||||||
public ApiClient() {
|
public ApiClient() {
|
||||||
httpClient = new OkHttpClient();
|
httpClient = new OkHttpClient();
|
||||||
|
|
||||||
|
{{#useGzipFeature}}
|
||||||
|
// Enable gzip request compression
|
||||||
|
httpClient.interceptors().add(new GzipRequestInterceptor());
|
||||||
|
{{/useGzipFeature}}
|
||||||
|
|
||||||
verifyingSsl = true;
|
verifyingSsl = true;
|
||||||
json = new JSON();
|
json = new JSON();
|
||||||
|
|
||||||
@ -835,6 +841,13 @@ public class ApiClient {
|
|||||||
if (returnType == null || response.code() == 204) {
|
if (returnType == null || response.code() == 204) {
|
||||||
// returning null if the returnType is not defined,
|
// returning null if the returnType is not defined,
|
||||||
// or the status code is 204 (No Content)
|
// or the status code is 204 (No Content)
|
||||||
|
if (response.body() != null) {
|
||||||
|
try {
|
||||||
|
response.body().close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap());
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return deserialize(response, returnType);
|
return deserialize(response, returnType);
|
||||||
|
@ -132,7 +132,8 @@ public class JSON {
|
|||||||
*/
|
*/
|
||||||
public static class DateTimeTypeAdapter extends TypeAdapter<DateTime> {
|
public static class DateTimeTypeAdapter extends TypeAdapter<DateTime> {
|
||||||
|
|
||||||
private DateTimeFormatter formatter;
|
private final DateTimeFormatter parseFormatter = ISODateTimeFormat.dateOptionalTimeParser();
|
||||||
|
private final DateTimeFormatter printFormatter = ISODateTimeFormat.dateTime();
|
||||||
|
|
||||||
public DateTimeTypeAdapter() {
|
public DateTimeTypeAdapter() {
|
||||||
this(ISODateTimeFormat.dateTime().withOffsetParsed());
|
this(ISODateTimeFormat.dateTime().withOffsetParsed());
|
||||||
@ -151,7 +152,7 @@ public class JSON {
|
|||||||
if (date == null) {
|
if (date == null) {
|
||||||
out.nullValue();
|
out.nullValue();
|
||||||
} else {
|
} else {
|
||||||
out.value(formatter.print(date));
|
out.value(printFormatter.print(date));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +164,7 @@ public class JSON {
|
|||||||
return null;
|
return null;
|
||||||
default:
|
default:
|
||||||
String date = in.nextString();
|
String date = in.nextString();
|
||||||
return formatter.parseDateTime(date);
|
return parseFormatter.parseDateTime(date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,8 @@ public class ApiClient {
|
|||||||
*/
|
*/
|
||||||
public ApiClient() {
|
public ApiClient() {
|
||||||
httpClient = new OkHttpClient();
|
httpClient = new OkHttpClient();
|
||||||
|
|
||||||
|
|
||||||
verifyingSsl = true;
|
verifyingSsl = true;
|
||||||
json = new JSON();
|
json = new JSON();
|
||||||
|
|
||||||
@ -820,6 +822,13 @@ public class ApiClient {
|
|||||||
if (returnType == null || response.code() == 204) {
|
if (returnType == null || response.code() == 204) {
|
||||||
// returning null if the returnType is not defined,
|
// returning null if the returnType is not defined,
|
||||||
// or the status code is 204 (No Content)
|
// or the status code is 204 (No Content)
|
||||||
|
if (response.body() != null) {
|
||||||
|
try {
|
||||||
|
response.body().close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap());
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return deserialize(response, returnType);
|
return deserialize(response, returnType);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user