Skip to content

Fix NPE with cpp-restsdk client generator #1477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> o
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);
Expand All @@ -295,7 +295,7 @@ public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> o
}
return objs;
}

protected boolean isFileSchema(CodegenProperty property) {
return property.baseType.equals("HttpContent");
}
Expand Down Expand Up @@ -411,7 +411,6 @@ public String getSchemaType(Schema p) {

@Override
public Map<String, Object> postProcessAllModels(final Map<String, Object> models) {

final Map<String, Object> processed = super.postProcessAllModels(models);
postProcessParentModels(models);
return processed;
Expand All @@ -432,13 +431,18 @@ private void postProcessParentModels(final Map<String, Object> models) {
*/
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;
}
}
}
}
Expand Down