Skip to content

Commit 32f7398

Browse files
committed
Merge pull request #1270 from maxime-morand/develop_2.0
Fixes swagger-api/swagger-codegen#980 : Allowing inheritance without additonal properties
2 parents 38673c9 + 6d5ac06 commit 32f7398

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

modules/swagger-core/src/main/java/io/swagger/util/ModelDeserializer.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,22 @@ public Model deserialize(JsonParser jp, DeserializationContext ctxt)
3131
// we only support one parent, no multiple inheritance or composition
3232
model = Json.mapper().convertValue(node, ComposedModel.class);
3333
List<Model> allComponents = model.getAllOf();
34-
if (allComponents.size() >= 2) {
34+
if (allComponents.size() >= 1) {
3535
model.setParent(allComponents.get(0));
36-
model.setChild(allComponents.get(allComponents.size() - 1));
37-
}
38-
if (allComponents.size() >= 2) {
39-
List<RefModel> interfaces = new ArrayList<RefModel>();
40-
int size = allComponents.size();
41-
for (Model m : allComponents.subList(1, size - 1)) {
42-
if (m instanceof RefModel) {
43-
RefModel ref = (RefModel) m;
44-
interfaces.add(ref);
45-
}
46-
}
47-
model.setInterfaces(interfaces);
36+
if (allComponents.size() >= 2) {
37+
model.setChild(allComponents.get(allComponents.size() - 1));
38+
List<RefModel> interfaces = new ArrayList<RefModel>();
39+
int size = allComponents.size();
40+
for (Model m : allComponents.subList(1, size - 1)) {
41+
if (m instanceof RefModel) {
42+
RefModel ref = (RefModel) m;
43+
interfaces.add(ref);
44+
}
45+
}
46+
model.setInterfaces(interfaces);
47+
} else {
48+
model.setChild(new ModelImpl());
49+
}
4850
}
4951
return model;
5052
} else {

0 commit comments

Comments
 (0)