We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I'd like to have my Pydantic models defined in snake_case but have the API return JSON with camelCase fields.
snake_case
camelCase
In FastAPI, I can do the following:
def to_camel(string: str): # returns "string" converted to camelCase class MyModel(BaseModel): foo_bar: str class Config: alias_generator = to_camel allow_population_by_field_name = True
And the resulting JSON will be {"fooBar": "x"}. This is similar to the way it's described in the Pydantic docs.
{"fooBar": "x"}
This doesn't work with flask-pydantic. Is there any way to achieve similar behaviour?
The text was updated successfully, but these errors were encountered:
Hi,
please refer to #15 where I implemented the solution.
Jirka
Sorry, something went wrong.
Model aliases for response models are added in newest version 0.4.0.
0.4.0
If you are not satisfied with solution or have another suggestion, please reopen this or create a new issue.
Thanks for the super quick fix, it's working well!
No branches or pull requests
I'd like to have my Pydantic models defined in
snake_case
but have the API return JSON withcamelCase
fields.In FastAPI, I can do the following:
And the resulting JSON will be
{"fooBar": "x"}
. This is similar to the way it's described in the Pydantic docs.This doesn't work with flask-pydantic. Is there any way to achieve similar behaviour?
The text was updated successfully, but these errors were encountered: