forked from loafle/openapi-generator-original
recursively add import for parameters (#5891)
This commit is contained in:
@@ -2410,7 +2410,12 @@ public class DefaultCodegen {
|
||||
p.baseType = pr.datatype;
|
||||
p.isContainer = true;
|
||||
p.isListContainer = true;
|
||||
imports.add(pr.baseType);
|
||||
|
||||
// recursively add import
|
||||
while (pr != null) {
|
||||
imports.add(pr.baseType);
|
||||
pr = pr.items;
|
||||
}
|
||||
} else if ("object".equals(type)) { // for map parameter
|
||||
Property inner = qp.getItems();
|
||||
if (inner == null) {
|
||||
@@ -2424,7 +2429,11 @@ public class DefaultCodegen {
|
||||
p.baseType = pr.datatype;
|
||||
p.isContainer = true;
|
||||
p.isMapContainer = true;
|
||||
imports.add(pr.baseType);
|
||||
// recursively add import
|
||||
while (pr != null) {
|
||||
imports.add(pr.baseType);
|
||||
pr = pr.items;
|
||||
}
|
||||
} else {
|
||||
Map<PropertyId, Object> args = new HashMap<PropertyId, Object>();
|
||||
String format = qp.getFormat();
|
||||
@@ -2502,6 +2511,7 @@ public class DefaultCodegen {
|
||||
}
|
||||
|
||||
} else {
|
||||
LOGGER.info("proessing body parameter ...");
|
||||
if (!(param instanceof BodyParameter)) {
|
||||
LOGGER.error("Cannot use Parameter " + param + " as Body Parameter");
|
||||
}
|
||||
@@ -2545,6 +2555,14 @@ public class DefaultCodegen {
|
||||
imports.add(cp.complexType);
|
||||
}
|
||||
imports.add(cp.baseType);
|
||||
|
||||
// recursively add import
|
||||
CodegenProperty innerCp = cp;
|
||||
while(innerCp != null) {
|
||||
imports.add(innerCp.complexType);
|
||||
innerCp = innerCp.items;
|
||||
}
|
||||
|
||||
p.items = cp;
|
||||
p.dataType = cp.datatype;
|
||||
p.baseType = cp.complexType;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user