[python-nextgen] use __fields_set__ to determine if the field is needed in to_dict (#15086)

* use __fields_set__ to determine if the field is needed

* fix tests
This commit is contained in:
William Cheng
2023-04-01 10:23:38 +08:00
committed by GitHub
parent 1710615fd8
commit 0dc84520e7
12 changed files with 73 additions and 34 deletions

View File

@@ -71,15 +71,18 @@ class DefaultValue(BaseModel):
},
exclude_none=True)
# set to None if array_string_nullable (nullable) is None
if self.array_string_nullable is None:
# and __fields_set__ contains the field
if self.array_string_nullable is None and "array_string_nullable" in self.__fields_set__:
_dict['array_string_nullable'] = None
# set to None if array_string_extension_nullable (nullable) is None
if self.array_string_extension_nullable is None:
# and __fields_set__ contains the field
if self.array_string_extension_nullable is None and "array_string_extension_nullable" in self.__fields_set__:
_dict['array_string_extension_nullable'] = None
# set to None if string_nullable (nullable) is None
if self.string_nullable is None:
# and __fields_set__ contains the field
if self.string_nullable is None and "string_nullable" in self.__fields_set__:
_dict['string_nullable'] = None
return _dict