[Python] Success constructor overwrites data
i have generated a python client via the swagger-codegen-cli (v3) docker image in my GitLab ci pipline for a Shopware 6 shop.
The problem is that the client overwrites the data befor returning it and it seems to be a problem in the generated constructor.
def __init__(self, data=None, links=None, *args, **kwargs): # noqa: E501
"""InlineResponse200156 - a model defined in Swagger""" # noqa: E501
self._data = None
self._links = None
self.discriminator = None
if data is not None:
self.data = data
if links is not None:
self.links = links
Success.__init__(self, *args, **kwargs)
I think the calll to the init() function of the parent class Success is either at the wrong place or the init() function of Success is wrong. In both init() functions the self._data gets initialized to None and even if the first init() (from the code above) sets the data to the data from my shop when the parent function is called it gets overwritten with None.
for referenc here is the init() function from the Success class:
def __init__(self, meta=None, links=None, data=None, included=None): # noqa: E501
"""Success - a model defined in Swagger""" # noqa: E501
self._meta = None
self._links = None
self._data = None
self._included = None
self.discriminator = None
if meta is not None:
self.meta = meta
if links is not None:
self.links = links
self.data = data
if included is not None:
self.included = included
This problem is in all classes in my model that inherent Success and one solution would be to change it that the init() call to the parent would be called befor the data is set.
Like so:
def __init__(self, data=None, links=None, *args, **kwargs): # noqa: E501
"""InlineResponse200156 - a model defined in Swagger""" # noqa: E501
Success.__init__(self, *args, **kwargs)
self._data = None
self._links = None
self.discriminator = None
if data is not None:
self.data = data
if links is not None:
self.links = links
This affected me as well, the proposed fix in the linked PR solved the issue for me. Is there any chance it could be reviewed and merged?