[Java] [Native] Add response body to exception message (#9169)

* Fix #8027 - import the auto generated supporting JSON class only when generateSupportingFiles is true

* Fix #8027 - import the auto generated supporting JSON class only when generateSupportingFiles is true

* Fix #8027 - import the auto generated supporting JSON class only when generateSupportingFiles is true

* Revert "Fix #8027 - import the auto generated supporting JSON class only when generateSupportingFiles is true"

This reverts commit 56e2b1fb

* Revert "Fix #8027 - import the auto generated supporting JSON class only when generateSupportingFiles is true"

This reverts commit 335c304d

* Fix #8027 - import the auto generated supporting JSON class only when generateSupportingFiles is true

* Fix #8027 - import the auto generated supporting JSON class only when discriminator is needed

* Fix #8027 - import the auto generated supporting JSON class only when discriminator is needed

* Fix #8027 - import the auto generated supporting JSON class only when discriminator is needed

* [Java] [Native] Add response body to exception message

* [Java] [Native] Use default base URI if baseUri param is null

* [Java] [Native] Use default base URI if baseUri param is null
This commit is contained in:
Moshe Elisha
2021-04-16 06:02:56 +03:00
committed by GitHub
parent 6dce8179de
commit af992e4b29
24 changed files with 241 additions and 312 deletions

View File

@@ -175,7 +175,7 @@ public class ApiClient {
public ApiClient(HttpClient.Builder builder, ObjectMapper mapper, String baseUri) {
this.builder = builder;
this.mapper = mapper;
updateBaseUri(baseUri);
updateBaseUri(baseUri != null ? baseUri : getDefaultBaseUri());
interceptor = null;
readTimeout = null;
responseInterceptor = null;

View File

@@ -67,6 +67,14 @@ public class AnotherFakeApi {
localVarResponse.body());
}
protected ApiException createApiException(HttpResponse<InputStream> response, String msgPrefix) throws IOException {
String body = response.body() == null ? null : new String(response.body().readAllBytes());
if (body != null) {
msgPrefix += ": " + body;
}
return new ApiException(response.statusCode(), msgPrefix, response.headers(), body);
}
/**
* To test special tags
* To test special tags and operation ID starting with number

View File

@@ -75,6 +75,14 @@ public class FakeApi {
localVarResponse.body());
}
protected ApiException createApiException(HttpResponse<InputStream> response, String msgPrefix) throws IOException {
String body = response.body() == null ? null : new String(response.body().readAllBytes());
if (body != null) {
msgPrefix += ": " + body;
}
return new ApiException(response.statusCode(), msgPrefix, response.headers(), body);
}
/**
* creates an XmlItem
* this route creates an XmlItem

View File

@@ -67,6 +67,14 @@ public class FakeClassnameTags123Api {
localVarResponse.body());
}
protected ApiException createApiException(HttpResponse<InputStream> response, String msgPrefix) throws IOException {
String body = response.body() == null ? null : new String(response.body().readAllBytes());
if (body != null) {
msgPrefix += ": " + body;
}
return new ApiException(response.statusCode(), msgPrefix, response.headers(), body);
}
/**
* To test class name in snake case
* To test class name in snake case

View File

@@ -70,6 +70,14 @@ public class PetApi {
localVarResponse.body());
}
protected ApiException createApiException(HttpResponse<InputStream> response, String msgPrefix) throws IOException {
String body = response.body() == null ? null : new String(response.body().readAllBytes());
if (body != null) {
msgPrefix += ": " + body;
}
return new ApiException(response.statusCode(), msgPrefix, response.headers(), body);
}
/**
* Add a new pet to the store
*

View File

@@ -67,6 +67,14 @@ public class StoreApi {
localVarResponse.body());
}
protected ApiException createApiException(HttpResponse<InputStream> response, String msgPrefix) throws IOException {
String body = response.body() == null ? null : new String(response.body().readAllBytes());
if (body != null) {
msgPrefix += ": " + body;
}
return new ApiException(response.statusCode(), msgPrefix, response.headers(), body);
}
/**
* Delete purchase order by ID
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors

View File

@@ -67,6 +67,14 @@ public class UserApi {
localVarResponse.body());
}
protected ApiException createApiException(HttpResponse<InputStream> response, String msgPrefix) throws IOException {
String body = response.body() == null ? null : new String(response.body().readAllBytes());
if (body != null) {
msgPrefix += ": " + body;
}
return new ApiException(response.statusCode(), msgPrefix, response.headers(), body);
}
/**
* Create user
* This can only be done by the logged in user.