@@ -787,21 +787,26 @@ private ExtendedCodegenModel processCodeGenModel(ExtendedCodegenModel cm) {
787787 .map (CodegenComposedSchemas ::getOneOf )
788788 .orElse (Collections .emptyList ());
789789
790+ // create a set of any non-primitive types used in the oneOf schemas which will need to
791+ // be imported.
790792 cm .oneOfModels = oneOfsList .stream ()
791- .filter (CodegenProperty :: getIsModel )
793+ .filter (cp -> ! cp . getIsPrimitiveType () )
792794 .map (CodegenProperty ::getBaseType )
793795 .filter (Objects ::nonNull )
794796 .collect (Collectors .toCollection (TreeSet ::new ));
795797
798+ // create a set of any complex, inner types used by arrays in the oneOf schema (e.g. if
799+ // the oneOf uses Array<Foo>, Foo needs to be imported).
796800 cm .oneOfArrays = oneOfsList .stream ()
797801 .filter (CodegenProperty ::getIsArray )
798802 .map (CodegenProperty ::getComplexType )
799803 .filter (Objects ::nonNull )
800804 .collect (Collectors .toCollection (TreeSet ::new ));
801805
806+ // create a set of primitive types used in the oneOf schemas for use in the to & from
807+ // typed JSON methods.
802808 cm .oneOfPrimitives = oneOfsList .stream ()
803809 .filter (CodegenProperty ::getIsPrimitiveType )
804- .filter (Objects ::nonNull )
805810 .collect (Collectors .toCollection (HashSet ::new ));
806811
807812 if (!cm .oneOf .isEmpty ()) {
@@ -1485,6 +1490,9 @@ public class ExtendedCodegenModel extends CodegenModel {
14851490 @ Getter @ Setter
14861491 public Set <String > modelImports = new TreeSet <String >();
14871492
1493+ // oneOfModels, oneOfArrays & oneOfPrimitives contain a list of types used in schemas
1494+ // composed with oneOf and are used to define the import list and the to & from
1495+ // 'TypedJSON' conversion methods in the composed model classes.
14881496 @ Getter @ Setter
14891497 public Set <String > oneOfModels = new TreeSet <>();
14901498 @ Getter @ Setter
0 commit comments