Skip to content
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

Fix for $ref as last element in allOf error #8476

Merged
merged 1 commit into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
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 @@ -1383,7 +1383,7 @@ public CodegenModel fromModel(String name, Model model, Map<String, Model> allDe
allRequired = null;
}
// parent model
RefModel parent = (RefModel) composed.getParent();
Model parent = (Model) composed.getParent();

// interfaces (intermediate models)
if (composed.getInterfaces() != null) {
Expand Down Expand Up @@ -1416,16 +1416,31 @@ public CodegenModel fromModel(String name, Model model, Map<String, Model> allDe
}

if (parent != null) {
final String parentRef = parent.getSimpleRef();
m.parentSchema = parentRef;
m.parent = toModelName(parent.getSimpleRef());
addImport(m, m.parent);
if (allDefinitions != null) {
final Model parentModel = allDefinitions.get(m.parentSchema);
if (supportsInheritance) {
addProperties(allProperties, allRequired, parentModel, allDefinitions);
} else {
addProperties(properties, required, parentModel, allDefinitions);
String parentName = null;
if(parent instanceof RefModel) {
parentName = ((RefModel)parent).getSimpleRef();
}
else {
if(parent instanceof ModelImpl) {
// check for a title
ModelImpl parentImpl = (ModelImpl) parent;
if(StringUtils.isNotBlank(parentImpl.getTitle())) {
parentName = parentImpl.getTitle();
}
}
}

if(parentName != null) {
m.parentSchema = parentName;
m.parent = toModelName(parentName);
addImport(m, m.parent);
if (allDefinitions != null) {
final Model parentModel = allDefinitions.get(m.parentSchema);
if (supportsInheritance) {
addProperties(allProperties, allRequired, parentModel, allDefinitions);
} else {
addProperties(properties, required, parentModel, allDefinitions);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,9 @@ private Model getParent(Model model) {
models.putAll(config.additionalProperties());
allProcessedModels.put(name, models);
} catch (Exception e) {
throw new RuntimeException("Could not process model '" + name + "'" + ".Please make sure that your schema is correct!", e);
String message = "Could not process model '" + name + "'" + ". Please make sure that your schema is correct!";
LOGGER.error(message, e);
throw new RuntimeException(message, e);
}
}

Expand Down