You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A model with a property of type Union[Unset, List[SomeEnum]]initializes correctly when using __init__ initialization:
>>># with non-empty list>>>SomeRequestBody(my_optional_list=[SomeEnum.FOO])
SomeRequestBody(my_optional_list=[<SomeEnum.FOO: 'FOO'>], additional_properties={})
>>># with empty list>>>SomeRequestBody()
SomeRequestBody(my_optional_list=<fake_spec_client.types.Unsetobjectat0x7ff2001db9d0>, additional_properties={})
BUT, when I initialize it using .from_dict() method, unexpectedly it provides an empty list as a default value:
>>># everything's fine when passing an explicit value>>>SomeRequestBody.from_dict(dict(my_optional_list=['FOO']))
SomeRequestBody(my_optional_list=[<SomeEnum.FOO: 'FOO'>], additional_properties={})
>>># but this is not expected. I'd expect the same result as from regular initialization SomeRequestBody() >>>SomeRequestBody.from_dict(dict())
SomeRequestBody(my_optional_list=[], additional_properties={})
From my point of view, .from_dict() initialization should keep align with the logic in __init__ initialization.
I have two optional lists, and I want to be able to set one to [] without doing anything to the other. However, if I do a MyModel.from_dict({'myoptionallist': None}), both 'myoptionallist' and 'myotheroptionallist' get set to [].
Describe the bug
A model with a property of type
Union[Unset, List[SomeEnum]]
initializes correctly when using__init__
initialization:BUT, when I initialize it using
.from_dict()
method, unexpectedly it provides an empty list as a default value:From my point of view,
.from_dict()
initialization should keep align with the logic in__init__
initialization.OpenAPI Spec File
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: