forked from loafle/openapi-generator-original
[python-pydantic-v1] Fix unnamed dicts with additional properties (#18112)
* [python-pydantic-v1] pick #16779 * [python] update sample
This commit is contained in:
@@ -57,7 +57,7 @@ class MapOfArrayOfModel(BaseModel):
|
||||
_field_dict_of_array = {}
|
||||
if self.shop_id_to_org_online_lip_map:
|
||||
for _key in self.shop_id_to_org_online_lip_map:
|
||||
if self.shop_id_to_org_online_lip_map[_key]:
|
||||
if self.shop_id_to_org_online_lip_map[_key] is not None:
|
||||
_field_dict_of_array[_key] = [
|
||||
_item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key]
|
||||
]
|
||||
|
||||
@@ -57,7 +57,7 @@ class UnnamedDictWithAdditionalModelListProperties(BaseModel):
|
||||
_field_dict_of_array = {}
|
||||
if self.dict_property:
|
||||
for _key in self.dict_property:
|
||||
if self.dict_property[_key]:
|
||||
if self.dict_property[_key] is not None:
|
||||
_field_dict_of_array[_key] = [
|
||||
_item.to_dict() for _item in self.dict_property[_key]
|
||||
]
|
||||
|
||||
@@ -52,15 +52,6 @@ class UnnamedDictWithAdditionalStringListProperties(BaseModel):
|
||||
exclude={
|
||||
},
|
||||
exclude_none=True)
|
||||
# override the default output from pydantic by calling `to_dict()` of each value in dict_property (dict of array)
|
||||
_field_dict_of_array = {}
|
||||
if self.dict_property:
|
||||
for _key in self.dict_property:
|
||||
if self.dict_property[_key]:
|
||||
_field_dict_of_array[_key] = [
|
||||
_item.to_dict() for _item in self.dict_property[_key]
|
||||
]
|
||||
_dict['dictProperty'] = _field_dict_of_array
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user