You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This propagates into the generated model_utils.py file. It will result in failed operations if you try to copy() an OpenApiModel object.
openapi-generator version
This is present in the master branch but also 5.3.0
OpenAPI declaration file content or url
This is reproducible using the petstore sample already present in the repo.
Generation Details
None. Use petstore sample.
Steps to reproduce
From the openapi-generator/samples/client/petstore/python directory, launch Python and run
importpetstore_apifrompetstore_api.model.class_modelimportClassModelimportcopya=ClassModel()
b=copy.deepcopy(a) # OKc=copy.copy(a) # Raises an error
It produces an error like:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/copy.py", line 84, in copy
return copier(x)
File "/home/user/openapi-generator/samples/client/petstore/python/petstore_api/model_utils.py", line 195, in __copy__
return new_cls.__new__(cls, **self.__dict__)
NameError: name 'new_cls' is not defined
tuanchien
changed the title
[BUG][Python] model_template __copy__ refers to new_cls (undefined)
[BUG][Python] model template __copy__ refers to new_cls (undefined)
Nov 15, 2021
aroelo
pushed a commit
to The-Academic-Observatory/observatory-platform
that referenced
this issue
Dec 15, 2021
Bug Report Checklist
Description
The Python generator template's
__copy__
function refers tonew_cls
, which is not defined in the function.See:
openapi-generator/modules/openapi-generator/src/main/resources/python/model_templates/methods_shared.mustache
Line 22 in 9464999
This propagates into the generated
model_utils.py
file. It will result in failed operations if you try tocopy()
anOpenApiModel
object.openapi-generator version
This is present in the master branch but also 5.3.0
OpenAPI declaration file content or url
This is reproducible using the petstore sample already present in the repo.
Generation Details
None. Use petstore sample.
Steps to reproduce
From the
openapi-generator/samples/client/petstore/python
directory, launch Python and runIt produces an error like:
Related issues/PRs
Suggest a fix
Change
openapi-generator/modules/openapi-generator/src/main/resources/python/model_templates/methods_shared.mustache
Line 22 in 9464999
to
The text was updated successfully, but these errors were encountered: