New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python: obj.to_dict()
methods return wrong structures because they do not use attribute_map
#8948
Comments
any upates? |
going to assign to myself, thanks for remind |
in case you get tired of waiting :)
|
revised in light of additional bug (#9847) I found @HugoMario would be cool if we could fix this up.
|
@HugoMario Is there any update on this issue? Any hints where the fix should be deployed in the generator to generate the I'm using the latest version 3.0.19 and the bug is still there. |
I'm using the latest version 3.0.25 and the bug is still there. |
+1 |
Description
Generated model code does not make any use of the
attribute_map
table which holds the mapping between the OpenAPI property names and pythonic property names.If you have an object with
camelCaseProperty
, then swagger will generate a model with thecamel_case_property
field and record the mapping in theattribute_map
. Unfortunately, when callingobj.to_dict()
this map is not used and the resulting object will be incorrect.The proper conversion is be performed by the
ApiClient.sanitize_for_serialization
method which requires first creating the client object. I'm arguing that this conversion should be built-in theobj.to_dict()
methods. These methods should never return incorrect objects.Swagger-codegen version
2.3.1
Swagger declaration file content or url
Command line used for generation
java -jar swagger-codegen-cli.jar generate -l python -i experiment.swagger.json -o $DIR -c config.json
Suggest a fix/enhancement
The
attribute_map
conversion should be built-in theobj.to_dict()
methods.The text was updated successfully, but these errors were encountered: