forked from loafle/openapi-generator-original
fix(swift3): multi-level inheritance support
Supports multi-level inheritance to avoid having the variables from the parents of level > 2 This commit also fixes the comparison of the variables when skipping the variables in the children classes by only comparing their names (in some cases some parent variables were present in children classes) Signed-off-by: Vincent Giersch <vincent@giersch.fr>
This commit is contained in:
@@ -427,10 +427,18 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
if(codegenModel.description != null) {
|
||||
codegenModel.imports.add("ApiModel");
|
||||
}
|
||||
if (allDefinitions != null && codegenModel.parentSchema != null) {
|
||||
final Model parentModel = allDefinitions.get(codegenModel.parentSchema);
|
||||
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
|
||||
if (allDefinitions != null) {
|
||||
String parentSchema = codegenModel.parentSchema;
|
||||
|
||||
// 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);
|
||||
|
||||
// get the next parent
|
||||
parentSchema = parentCodegenModel.parentSchema;
|
||||
}
|
||||
}
|
||||
|
||||
return codegenModel;
|
||||
@@ -582,7 +590,7 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
Iterator<CodegenProperty> iterator = codegenProperties.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
CodegenProperty codegenProperty = iterator.next();
|
||||
if (codegenProperty.equals(parentModelCodegenProperty)) {
|
||||
if (codegenProperty.baseName == parentModelCodegenProperty.baseName) {
|
||||
// We found a property in the child class that is
|
||||
// a duplicate of the one in the parent, so remove it.
|
||||
iterator.remove();
|
||||
|
||||
Reference in New Issue
Block a user