Merge pull request #1818 from swagger-api/issue-1817

updated parentModel names in inheritence situations
This commit is contained in:
Tony Tam 2016-01-05 15:22:22 -08:00
commit d5f17a1c3b
3 changed files with 6 additions and 6 deletions

View File

@ -788,9 +788,9 @@ public class DefaultCodegen {
// parent model
final RefModel parent = (RefModel) composed.getParent();
if (parent != null) {
final String parentRef = toModelName(parent.getSimpleRef());
final String parentRef = parent.getSimpleRef();
m.parent = parentRef;
addImport(m, parentRef);
addImport(m, toModelName(parent.getSimpleRef()));
if (!supportsInheritance && allDefinitions != null) {
final Model parentModel = allDefinitions.get(parentRef);
if (parentModel instanceof ModelImpl) {

View File

@ -456,7 +456,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions);
if (allDefinitions != null && codegenModel != null && codegenModel.parent != null && codegenModel.hasEnums) {
final Model parentModel = allDefinitions.get(toModelName(codegenModel.parent));
final Model parentModel = allDefinitions.get(codegenModel.parent);
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
codegenModel = this.reconcileInlineEnums(codegenModel, parentCodegenModel);
}

View File

@ -73,14 +73,14 @@ public class JavaModelEnumTest {
final DefaultCodegen codegen = new JavaClientCodegen();
final Map<String, Model> allModels = new HashMap<String, Model>();
allModels.put(codegen.toModelName(parentModel.getName()), parentModel);
allModels.put(codegen.toModelName(subModel.getName()), subModel);
allModels.put(parentModel.getName(), parentModel);
allModels.put(subModel.getName(), subModel);
final CodegenModel cm = codegen.fromModel("sample", model, allModels);
Assert.assertEquals(cm.name, "sample");
Assert.assertEquals(cm.classname, "Sample");
Assert.assertEquals(cm.parent, "ParentModel");
Assert.assertEquals(cm.parent, "parentModel");
Assert.assertTrue(cm.imports.contains("ParentModel"));
// Assert that only the unshared/uninherited enum remains