forked from loafle/openapi-generator-original
[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 commit56e2b1fb* Revert "Fix #8027 - import the auto generated supporting JSON class only when generateSupportingFiles is true" This reverts commit335c304d* 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:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -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 < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user