mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
* Update ApiClient.mustache Fix for issue #5777 * Update ApiClient.mustache * Create ApiClient.mustache * Run java-petstore-jersey2.sh
This commit is contained in:
parent
77c14bca39
commit
f2276e5b35
@ -682,48 +682,56 @@ public class ApiClient {
|
||||
|
||||
Entity<?> entity = serialize(body, formParams, contentType);
|
||||
|
||||
Response response;
|
||||
Response response = null;
|
||||
|
||||
if ("GET".equals(method)) {
|
||||
response = invocationBuilder.get();
|
||||
} else if ("POST".equals(method)) {
|
||||
response = invocationBuilder.post(entity);
|
||||
} else if ("PUT".equals(method)) {
|
||||
response = invocationBuilder.put(entity);
|
||||
} else if ("DELETE".equals(method)) {
|
||||
response = invocationBuilder.delete();
|
||||
} else if ("PATCH".equals(method)) {
|
||||
response = invocationBuilder.header("X-HTTP-Method-Override", "PATCH").post(entity);
|
||||
} else {
|
||||
throw new ApiException(500, "unknown method type " + method);
|
||||
}
|
||||
|
||||
statusCode = response.getStatusInfo().getStatusCode();
|
||||
responseHeaders = buildResponseHeaders(response);
|
||||
|
||||
if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) {
|
||||
return null;
|
||||
} else if (response.getStatusInfo().getFamily() == Status.Family.SUCCESSFUL) {
|
||||
if (returnType == null)
|
||||
return null;
|
||||
else
|
||||
return deserialize(response, returnType);
|
||||
} else {
|
||||
String message = "error";
|
||||
String respBody = null;
|
||||
if (response.hasEntity()) {
|
||||
try {
|
||||
respBody = String.valueOf(response.readEntity(String.class));
|
||||
message = respBody;
|
||||
} catch (RuntimeException e) {
|
||||
// e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if ("GET".equals(method)) {
|
||||
response = invocationBuilder.get();
|
||||
} else if ("POST".equals(method)) {
|
||||
response = invocationBuilder.post(entity);
|
||||
} else if ("PUT".equals(method)) {
|
||||
response = invocationBuilder.put(entity);
|
||||
} else if ("DELETE".equals(method)) {
|
||||
response = invocationBuilder.delete();
|
||||
} else if ("PATCH".equals(method)) {
|
||||
response = invocationBuilder.header("X-HTTP-Method-Override", "PATCH").post(entity);
|
||||
} else {
|
||||
throw new ApiException(500, "unknown method type " + method);
|
||||
}
|
||||
|
||||
statusCode = response.getStatusInfo().getStatusCode();
|
||||
responseHeaders = buildResponseHeaders(response);
|
||||
|
||||
if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) {
|
||||
return null;
|
||||
} else if (response.getStatusInfo().getFamily() == Status.Family.SUCCESSFUL) {
|
||||
if (returnType == null)
|
||||
return null;
|
||||
else
|
||||
return deserialize(response, returnType);
|
||||
} else {
|
||||
String message = "error";
|
||||
String respBody = null;
|
||||
if (response.hasEntity()) {
|
||||
try {
|
||||
respBody = String.valueOf(response.readEntity(String.class));
|
||||
message = respBody;
|
||||
} catch (RuntimeException e) {
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getStatus(),
|
||||
message,
|
||||
buildResponseHeaders(response),
|
||||
respBody);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
response.close();
|
||||
} catch (Exception e) {
|
||||
// it's not critical, since the response object is local in method invokeAPI; that's fine, just continue
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getStatus(),
|
||||
message,
|
||||
buildResponseHeaders(response),
|
||||
respBody);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -671,48 +671,56 @@ public class ApiClient {
|
||||
|
||||
Entity<?> entity = serialize(body, formParams, contentType);
|
||||
|
||||
Response response;
|
||||
Response response = null;
|
||||
|
||||
if ("GET".equals(method)) {
|
||||
response = invocationBuilder.get();
|
||||
} else if ("POST".equals(method)) {
|
||||
response = invocationBuilder.post(entity);
|
||||
} else if ("PUT".equals(method)) {
|
||||
response = invocationBuilder.put(entity);
|
||||
} else if ("DELETE".equals(method)) {
|
||||
response = invocationBuilder.delete();
|
||||
} else if ("PATCH".equals(method)) {
|
||||
response = invocationBuilder.header("X-HTTP-Method-Override", "PATCH").post(entity);
|
||||
} else {
|
||||
throw new ApiException(500, "unknown method type " + method);
|
||||
}
|
||||
|
||||
statusCode = response.getStatusInfo().getStatusCode();
|
||||
responseHeaders = buildResponseHeaders(response);
|
||||
|
||||
if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) {
|
||||
return null;
|
||||
} else if (response.getStatusInfo().getFamily() == Status.Family.SUCCESSFUL) {
|
||||
if (returnType == null)
|
||||
return null;
|
||||
else
|
||||
return deserialize(response, returnType);
|
||||
} else {
|
||||
String message = "error";
|
||||
String respBody = null;
|
||||
if (response.hasEntity()) {
|
||||
try {
|
||||
respBody = String.valueOf(response.readEntity(String.class));
|
||||
message = respBody;
|
||||
} catch (RuntimeException e) {
|
||||
// e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if ("GET".equals(method)) {
|
||||
response = invocationBuilder.get();
|
||||
} else if ("POST".equals(method)) {
|
||||
response = invocationBuilder.post(entity);
|
||||
} else if ("PUT".equals(method)) {
|
||||
response = invocationBuilder.put(entity);
|
||||
} else if ("DELETE".equals(method)) {
|
||||
response = invocationBuilder.delete();
|
||||
} else if ("PATCH".equals(method)) {
|
||||
response = invocationBuilder.header("X-HTTP-Method-Override", "PATCH").post(entity);
|
||||
} else {
|
||||
throw new ApiException(500, "unknown method type " + method);
|
||||
}
|
||||
|
||||
statusCode = response.getStatusInfo().getStatusCode();
|
||||
responseHeaders = buildResponseHeaders(response);
|
||||
|
||||
if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) {
|
||||
return null;
|
||||
} else if (response.getStatusInfo().getFamily() == Status.Family.SUCCESSFUL) {
|
||||
if (returnType == null)
|
||||
return null;
|
||||
else
|
||||
return deserialize(response, returnType);
|
||||
} else {
|
||||
String message = "error";
|
||||
String respBody = null;
|
||||
if (response.hasEntity()) {
|
||||
try {
|
||||
respBody = String.valueOf(response.readEntity(String.class));
|
||||
message = respBody;
|
||||
} catch (RuntimeException e) {
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getStatus(),
|
||||
message,
|
||||
buildResponseHeaders(response),
|
||||
respBody);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
response.close();
|
||||
} catch (Exception e) {
|
||||
// it's not critical, since the response object is local in method invokeAPI; that's fine, just continue
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getStatus(),
|
||||
message,
|
||||
buildResponseHeaders(response),
|
||||
respBody);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user