fix: Union type on components (#4137)
* 🐛 (type_extraction.py): fix condition to correctly handle UnionType objects in type extraction process * ✨ (test_schema.py): add support for additional data types and nested structures in post_process_type function to improve type handling and flexibility * ✅ (test_schema.py): add additional test cases for post_process_type function to cover various Union types and combinations for better test coverage and accuracy
This commit is contained in:
parent
e043964585
commit
db2c12183c
2 changed files with 59 additions and 4 deletions
|
|
@ -55,7 +55,9 @@ def post_process_type(_type):
|
|||
|
||||
# If the return type is not a Union, then we just return it as a list
|
||||
inner_type = _type[0] if isinstance(_type, list) else _type
|
||||
if not hasattr(inner_type, "__origin__") or inner_type.__origin__ != Union:
|
||||
if (not hasattr(inner_type, "__origin__") or inner_type.__origin__ != Union) and (
|
||||
not hasattr(inner_type, "__class__") or inner_type.__class__.__name__ != "UnionType"
|
||||
):
|
||||
return _type if isinstance(_type, list) else [_type]
|
||||
# If the return type is a Union, then we need to parse it
|
||||
_type = extract_union_types_from_generic_alias(_type)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue