-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[BUG] Python generator generating reserved word ("from") #7119
Comments
I have a nearly identical scenario, where the "del" reserved operator is generated and used as an assignment inside the make_instance method, and it reproduces on 4.2.3 and 5.0.3b. |
Having the same problem with a nested "self" unfortunately.
Tested with v5.0.0-beta3 and 4.3.1. |
I have the same exact issue, were you able to find a past version that this was resolved in? |
I had a similar issue while using the keyword
hope that can help you. |
I am hitting this error (specifically with |
This is working in v6.2.0 and onward in the python client if the invalidly named property has an inline schema. One can see a passing test at: |
Bug Report Checklist
Description
When using the python generator (not the experimental one) the provided spec generates a python test that uses a reserved word as a variable name. This causes python to blow up.
The spec has to have this property: A python reserved word is used as a nested property in a schema (FailureStats -> FailureStat -> from). From is a reserved word in python but is not escaped because it's nested. In the provided sample it ends up being generated in a test file:
openapi-generator version
v4.3.1 (implementation-version: 4.3.1). Does not appear to be a regression that I can see.
OpenAPI declaration file content or url
Command line used for generation
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i spec3.yaml -g python -o ./output/
Steps to reproduce
Download openapi-generator-cli.jar from github.
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i spec3.yaml -g python -o ./output/
pytest ./output/test/
Related issues/PRs
I couldnt find any that seemed to mimic this issue for python.
Suggest a fix
In PythonClientCodegen.java. On line 872. Just add the following:
The text was updated successfully, but these errors were encountered: