to create a Wrapper object with an empty ListOfNumbers and I serialize it using the code below
python
from xsdata.formats.dataclass.serializers import XmlSerializer
from xsdata.formats.dataclass.serializers.config import SerializerConfig
from generated.schema import Wrapper
obj = Wrapper()
obj.list_of_numbers = []
config = SerializerConfig(pretty_print=True)
serializer = XmlSerializer(config)
print(serializer.render(obj))
The ListOfNumbers element do not get serialized which results in the following XML file.
xml
<?xml version="1.0" encoding="UTF-8"?><Wrapper/>
First of all, is this the expected behaviour ? I find it surprising to not have an empty element in the generated XML, which I expected to look somewhat like this
If this is the expected behaviour, would you be open to a pull request adding an option to serialize empty lists as empty elements rather than discard them?