-
-
Notifications
You must be signed in to change notification settings - Fork 307
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
Reserved name populated by snake-case-field #385
Comments
@yuyupopo I'm working on improve field_name. self.model_resolver.get_valid_field_name_and_alias |
We may need to split the class to |
But it seems that field preprocessors are called after |
Yes. |
First of all, I believe resolving this issue won't effect existing programs, because it is mentioning a corner case that generation fails. Second, splitting the functionality of resolving/generating field names/values) into Third, I have a suggestion. This project have grown quite large. There are many control knobs that users can change (almost all arguments to
|
OK, I will split the function to
I think the options should be explained in the documents. #133 Thank you |
@yuyupopo |
No worries :) Thx for the fix |
Describe the bug
When a property name is
Global
, and--snake-case-field
option is given, the generator creates a pydantic model namedglobal
which fails, becauseglobal
is a reserved keyword.To Reproduce
Below is a command to generator models from docker engine api.
The docker engine api has a schema(
Mode
) that hasGlobal
as property name.Used commandline:
Expected behavior
I expect that code generator would select another name rather than
global
. such asglobal_
.Solution Idea
We can add an underscore if the lowercased string is reserved.
parser.base.py:camel_to_snake
I've tested this out.
Version:
The text was updated successfully, but these errors were encountered: