tefra / xsdata

Naive XML & JSON Bindings for python
https://xsdata.readthedocs.io
MIT License
310 stars 56 forks source link

Please bring back support for optional lists #1051

Closed lewiscabban-swordfish closed 1 month ago

lewiscabban-swordfish commented 1 month ago

Support was removed in 24.5

We have an application that converts between JSON and XML and have been using support for optional lists to translate between the two sides. We need this because in our context there is a semantic difference between setting a field to empty list and not setting the field at all.

Previously we had fields that looked like below that would correctly translate between our JSON schema and XML schema:

some_field: Optional[list[float]]] = field(default=None, metadata={"type": "Attribute", "tokens": True})

Now this is forbidden, and there's no note in the changelog as to the reason this should be so. Perhaps this was part of the refactor?

Please consider adding support for optional lists back into the annotation analyzer.

tefra commented 1 month ago

Yeah this was never officially supported, and was removed in a recent refactor, I will add it back

tefra commented 1 month ago

Thanks @lewiscabban-swordfish the update is on main!