-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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 incorrectly renames valid model names #3428
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
I will look into it and create a pull request <- Memo to myself so I find the issue again :D |
This is actually a bigger issue concerning every generator. The function is implemented in the abstract generator which can not easily be changed since I do not know if casing is done before or after the function call An idea would be, since it changes the output of the generated code in every language, to add this fix as an opt in flag and to change it to default on the next breaking change release. |
Looking at the code I suspected that might be the case. For our current use case an optional flag on the Python generator would be helpful 👍 |
While refactoring I saw that half of the generators cheated and made their own solution instead of fixing this bug. Java for example did it in an most amusing way They are comparing a lower camelCased word with a lowercased one. All reserved words are lowercased. If they would have a camelCased word in the reserved list (which they do) that would not me marked as reserved. Well, guess I have to fix that now, too... |
…ase keywords as well as case sensitive keywords. Java, PHP and Python had changed, 65 unversioned sample files and 6 changed files. I also added a lot of TODOs to check whether the keywords of a gnerator should be registered case sensitive or not. DefaultCodegen got a new test where I demonstrated that the feature should work as intended. There could be a few bugs fixed in here where the input was lower cased but the reserved word not when comparing them I removed the old reservedWord and replaced it with two new version with case and without. They are also private so that they can not be used directly to assure consistent usage across the different generators
sorry that this issue is not yet patched in live. I still don't have all responses from the other code generator maintainers. I updated the project and will ask if it will be OK to potentially break the other generators since there are no maintainers listed or they didn't respond. |
Description
The generator is renaming valid model object names. Looking at https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java#L119 it seems that it is ignoring casing which means that valid names such as
Property
are being renamed toModelProperty
openapi-generator version
4.1.0-SNAPSHOT
OpenAPI declaration file content or url
Command line used for generation
Suggest a fix
Preserve casing when checking for keywords
The text was updated successfully, but these errors were encountered: