Skip to content
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

Key names are formatted in the target language, and not the source language #2421

Open
raldebsi opened this issue Oct 6, 2023 · 1 comment
Labels

Comments

@raldebsi
Copy link

raldebsi commented Oct 6, 2023

This is more of a request than an issue, but almost in all of my use case scenarios (at least in python) I've noticed that the classes being made are using python naming scheme (snake case) rather than the import JSON's scheme, which makes me unable to use the models generated without lots of modifications.
Example:

{
    "userName": "User1"
}

This would generate the following class:

class UserName(Enum):
    USER1 = "User1"

class Root:
    user_name: UserName

    def __init__(...)

This would not allow me to use the above model to reference the request response's JSON object, as user_name is not the right field. It is also worth noting that most code I've seen that deals with data models also rely on PyDantic / TypedDict, therefore inherting from TypedDict would also be optimal.

Therefore, is it possible to set a flag that would enable TypedDict + Original Naming Convention instead of using whatever is native to that language?

@renanzulian
Copy link

I'm dealing with the same problem. In my JSON samples, some fields are camelCase, and others are snake_case. It's impossible to have only the types with the original names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants