mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
Fix NPE with cpp-restsdk
client generator (#1477)
* fix_cpprest_npe * fix_code_format
This commit is contained in:
parent
7f8ff35245
commit
0e693cd9a8
@ -285,8 +285,8 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation op : operationList) {
|
||||
for(String hdr : op.imports) {
|
||||
if(importMapping.containsKey(hdr)) {
|
||||
for (String hdr : op.imports) {
|
||||
if (importMapping.containsKey(hdr)) {
|
||||
continue;
|
||||
}
|
||||
operations.put("hasModelImport", true);
|
||||
@ -295,7 +295,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
|
||||
protected boolean isFileSchema(CodegenProperty property) {
|
||||
return property.baseType.equals("HttpContent");
|
||||
}
|
||||
@ -411,7 +411,6 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessAllModels(final Map<String, Object> models) {
|
||||
|
||||
final Map<String, Object> processed = super.postProcessAllModels(models);
|
||||
postProcessParentModels(models);
|
||||
return processed;
|
||||
@ -432,13 +431,18 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||
*/
|
||||
private void processParentPropertiesInChildModel(final CodegenModel parent, final CodegenModel child) {
|
||||
final Map<String, CodegenProperty> childPropertiesByName = new HashMap<>(child.vars.size());
|
||||
for (final CodegenProperty childSchema : child.vars) {
|
||||
childPropertiesByName.put(childSchema.name, childSchema);
|
||||
if (child != null && child.vars != null && !child.vars.isEmpty()) {
|
||||
for (final CodegenProperty childSchema : child.vars) {
|
||||
childPropertiesByName.put(childSchema.name, childSchema);
|
||||
}
|
||||
}
|
||||
for (final CodegenProperty parentSchema : parent.vars) {
|
||||
final CodegenProperty duplicatedByParent = childPropertiesByName.get(parentSchema.name);
|
||||
if (duplicatedByParent != null) {
|
||||
duplicatedByParent.isInherited = true;
|
||||
|
||||
if (parent != null && parent.vars != null && !parent.vars.isEmpty()) {
|
||||
for (final CodegenProperty parentSchema : parent.vars) {
|
||||
final CodegenProperty duplicatedByParent = childPropertiesByName.get(parentSchema.name);
|
||||
if (duplicatedByParent != null) {
|
||||
duplicatedByParent.isInherited = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user