@@ -1236,7 +1236,6 @@ public static String getParentName(ComposedSchema composedSchema, Map<String, Sc
1236
1236
public static List <String > getAllParentsName (ComposedSchema composedSchema , Map <String , Schema > allSchemas , boolean includeAncestors ) {
1237
1237
List <Schema > interfaces = getInterfaces (composedSchema );
1238
1238
List <String > names = new ArrayList <String >();
1239
- List <String > refedWithoutDiscriminator = new ArrayList <>();
1240
1239
1241
1240
if (interfaces != null && !interfaces .isEmpty ()) {
1242
1241
for (Schema schema : interfaces ) {
@@ -1255,18 +1254,18 @@ public static List<String> getAllParentsName(ComposedSchema composedSchema, Map<
1255
1254
}
1256
1255
} else {
1257
1256
// not a parent since discriminator.propertyName is not set
1258
- refedWithoutDiscriminator .add (parentName );
1259
1257
}
1260
1258
} else {
1261
1259
// not a ref, doing nothing
1262
1260
}
1263
1261
}
1264
1262
}
1265
1263
1266
- if (names .size () == 0 && refedWithoutDiscriminator .size () == 1 ) {
1267
- LOGGER .warn ("[deprecated] inheritance without use of 'discriminator.propertyName' is deprecated " +
1268
- "and will be removed in a future release. Generating model for {}. Title: {}" , composedSchema .getName (), composedSchema .getTitle ());
1269
- return refedWithoutDiscriminator ;
1264
+ // ensure `allParents` always includes `parent`
1265
+ // this is more robust than keeping logic in getParentName() and getAllParentsName() in sync
1266
+ String parentName = getParentName (composedSchema , allSchemas );
1267
+ if (parentName != null && !names .contains (parentName )) {
1268
+ names .add (parentName );
1270
1269
}
1271
1270
1272
1271
return names ;
0 commit comments