Skip to content

Commit

Permalink
fix: support forced inclusion of array properties by using `@serializ…
Browse files Browse the repository at this point in the history
…able.include_none`

Signed-off-by: Paul Horton <paul.horton@owasp.org>
  • Loading branch information
madpah committed Sep 14, 2022
1 parent 12f9f97 commit 7ad0ecf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions serializable/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def _allow_property_for_view(prop_info: 'ObjectMetadataLibrary.SerializablePrope
allow_for_view = True

# Second check for inclusion of None values
if value_ is None:
if value_ is None or (prop_info.is_array and len(value_) < 1):
if not prop_info.include_none:
allow_for_view = False
elif prop_info.include_none and prop_info.include_none_views and view_ not in prop_info.include_none_views:
Expand Down Expand Up @@ -369,7 +369,7 @@ def _as_xml(self: _T, view_: Type[Any] = None, as_string: bool = True, element_n
elif prop_info.is_array and prop_info.xml_array_config:
_array_type, nested_key = prop_info.xml_array_config
nested_key = _namespace_element_name(tag_name=nested_key, xmlns=xmlns)
if _array_type and _array_type == XmlArraySerializationType.NESTED and len(v) > 0:
if _array_type and _array_type == XmlArraySerializationType.NESTED:
nested_e = ElementTree.SubElement(this_e, new_key)
else:
nested_e = this_e
Expand Down

0 comments on commit 7ad0ecf

Please sign in to comment.