forked from loafle/openapi-generator-original
Merge pull request #4202 from gierschv/fix-swift3-inheritance
fix(swift3): multi-level inheritance support
This commit is contained in:
commit
5b90276dae
@ -431,10 +431,18 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
if(codegenModel.description != null) {
|
if(codegenModel.description != null) {
|
||||||
codegenModel.imports.add("ApiModel");
|
codegenModel.imports.add("ApiModel");
|
||||||
}
|
}
|
||||||
if (allDefinitions != null && codegenModel.parentSchema != null) {
|
if (allDefinitions != null) {
|
||||||
final Model parentModel = allDefinitions.get(codegenModel.parentSchema);
|
String parentSchema = codegenModel.parentSchema;
|
||||||
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
|
|
||||||
|
// multilevel inheritance: reconcile properties of all the parents
|
||||||
|
while (parentSchema != null) {
|
||||||
|
final Model parentModel = allDefinitions.get(parentSchema);
|
||||||
|
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel, allDefinitions);
|
||||||
codegenModel = Swift3Codegen.reconcileProperties(codegenModel, parentCodegenModel);
|
codegenModel = Swift3Codegen.reconcileProperties(codegenModel, parentCodegenModel);
|
||||||
|
|
||||||
|
// get the next parent
|
||||||
|
parentSchema = parentCodegenModel.parentSchema;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return codegenModel;
|
return codegenModel;
|
||||||
@ -591,7 +599,7 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
Iterator<CodegenProperty> iterator = codegenProperties.iterator();
|
Iterator<CodegenProperty> iterator = codegenProperties.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
CodegenProperty codegenProperty = iterator.next();
|
CodegenProperty codegenProperty = iterator.next();
|
||||||
if (codegenProperty.equals(parentModelCodegenProperty)) {
|
if (codegenProperty.baseName == parentModelCodegenProperty.baseName) {
|
||||||
// We found a property in the child class that is
|
// We found a property in the child class that is
|
||||||
// a duplicate of the one in the parent, so remove it.
|
// a duplicate of the one in the parent, so remove it.
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user