@@ -75,6 +75,9 @@ def composed_model_input_classes(cls):
7575 This function returns a list of the possible models that can be accepted as
7676 inputs.
7777 """
78+ # Handle list types (e.g., [str], [float])
79+ if isinstance(cls, list):
80+ return [cls]
7881 if issubclass(cls, ModelSimple) or cls in PRIMITIVE_TYPES:
7982 return [cls]
8083 elif issubclass(cls, ModelNormal):
@@ -1557,17 +1560,44 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None):
15571560 # Empty data
15581561 oneof_instances.append(list_oneof_instance)
15591562 continue
1560- for arg in model_arg:
1561- if constant_kwargs.get("_spec_property_naming"):
1562- oneof_instance = oneof_class(
1563- **change_keys_js_to_python(arg, oneof_class), **constant_kwargs
1563+
1564+ # Check if inner type is primitive - follows same pattern as complex objects:
1565+ # https://github.com/DataDog/datadog-api-client-python/blob/008536d34760ce096e118edc54df613d82194529/.generator/src/generator/templates/model_utils.j2#L1590-L1599
1566+ if oneof_class in PRIMITIVE_TYPES:
1567+ # Handle list of primitives (e.g., [str], [float])
1568+ for arg in model_arg:
1569+ oneof_instance = validate_and_convert_types(
1570+ arg,
1571+ (oneof_class,),
1572+ constant_kwargs.get("_path_to_item", ()),
1573+ constant_kwargs.get("_spec_property_naming", False),
1574+ constant_kwargs.get("_check_type", True),
1575+ configuration=constant_kwargs.get("_configuration"),
15641576 )
1565- else:
1566- oneof_instance = oneof_class(**arg, **constant_kwargs)
1567- if not oneof_instance._unparsed:
15681577 list_oneof_instance.append(oneof_instance)
1569- if list_oneof_instance:
1570- oneof_instances.append(list_oneof_instance)
1578+ if list_oneof_instance:
1579+ oneof_instances.append(list_oneof_instance)
1580+ elif inspect.isclass(oneof_class) and issubclass(oneof_class, ModelSimple):
1581+ # Handle list of ModelSimple
1582+ for arg in model_arg:
1583+ oneof_instance = oneof_class(arg, **constant_kwargs)
1584+ if not oneof_instance._unparsed:
1585+ list_oneof_instance.append(oneof_instance)
1586+ if list_oneof_instance:
1587+ oneof_instances.append(list_oneof_instance)
1588+ else:
1589+ # Handle list of complex objects (ModelNormal, ModelComposed)
1590+ for arg in model_arg:
1591+ if constant_kwargs.get("_spec_property_naming"):
1592+ oneof_instance = oneof_class(
1593+ **change_keys_js_to_python(arg, oneof_class), **constant_kwargs
1594+ )
1595+ else:
1596+ oneof_instance = oneof_class(**arg, **constant_kwargs)
1597+ if not oneof_instance._unparsed:
1598+ list_oneof_instance.append(oneof_instance)
1599+ if list_oneof_instance:
1600+ oneof_instances.append(list_oneof_instance)
15711601 elif issubclass(oneof_class, ModelSimple):
15721602 if model_arg is not None:
15731603 oneof_instance = oneof_class(model_arg, **constant_kwargs)
0 commit comments