Open mfmarche opened 3 years ago
I had a bug in the last portion of the test, I missed the class_name. This works correctly with the suggested patch with copy and deepcopy with a discriminator type model as well.
deeppcopy(Mammal(class_name="BasquePig"))
Will this be addressed soon? I am running into the same issue in my own project and having to implement workarounds in the meantime.
Bug Report Checklist
Description
I ran into this as I was attempting to use dataclasses.asdict(obj). I tracked it down to use of a deepcopy call. While copying the openapi model object, I believe the default deepcopy is missing the object attributes.
openapi-generator version
master
OpenAPI declaration file content or url
I used the sample petstore api in: samples/openapi3/client/petstore/python
Generation Details
N/A
Steps to reproduce
Related issues/PRs
Suggest a fix
I came up with a solution to this by updating the model_utils.py, specifically the OpenApiModel, adding:
Note that this worked only for a Normal object without a discriminator. I ran into a separate issue (might be unrelated?), where the same test with a discriminator gave the following:
Could there be other pitfalls with implementation of the deepcopy above?