Bug - python client deserialization when attribute named self#9006
Bug - python client deserialization when attribute named self#9006spacether merged 10 commits intoOpenAPITools:masterfrom
self#9006Conversation
|
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors. Let me know if you need help fixing it. |
b8b716a to
0c292d3
Compare
|
@wing328 , it should be ok now. Thank you |
There was a problem hiding this comment.
@gbmarc1 Thank you for your PR. One goal with the python generator is to not treat any variable as special. If a name collision can happen, I have been adding an underscore in on the python side to prevent property name collisions.
So we don't use nullable as a class property, we use _nullable to allow a model to have a property named nullable.
Can you rename the self parameter in the model init signature to _self here?
That way our existing code will work and this variable is not handled in a special way outside of our model mustache templates.
Also, can you add a new schema that demonstrates this problem to our sample spec here: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml#L2320
And can you add a model test like we have here?
If we don't have a test of this and someone changes the code in the future we will not be able to detect when this feature breaks.
| call.respond(HttpStatusCode.Unauthorized) | ||
| } else { | ||
| call.respond(HttpStatusCode.NotImplemented) | ||
| } |
There was a problem hiding this comment.
@gbmarc1 Adding this ^M looks incorrect
Are you on unix?
It could be from this issue: https://stackoverflow.com/questions/5843495/what-does-m-character-mean-in-vim
Looks like a platform specific newline is being used.
There was a problem hiding this comment.
ok I will revert that changes for those files
This reverts commit 6fc9712.
|
@spacether
|
|
Any idea why CI\Circleci build fails? Error seems unrelated to this PR |
That error is unrelated to this PR. |
spacether
left a comment
There was a problem hiding this comment.
Thank you for your PR and adding the test case. This looks good.
@taxpon @frol @mbohlool @cbornet @kenjones-cisco @tomplus @Jyhess @arun-nalla @spacether
When an attribute is named
selfin model__init__fails becauseselfis in kwargs. Generation mapsselfto_selfproperly. However, when calling the endpoint the deserialization fails.PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.For Windows users, please run the script in Git BASH.
master,5.1.x,6.0.x