mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 18:45:23 +00:00
Merge pull request #1818 from swagger-api/issue-1817
updated parentModel names in inheritence situations
This commit is contained in:
commit
d5f17a1c3b
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user