sqlalchemy-pydantic-orm
sqlalchemy-pydantic-orm copied to clipboard
Integrate with fastapi_camelcase
I think we need some kind of possibility to mix sqlalchemy_pydantic_orm.ORMBaseSchema
and fastapi_camelcase.CamelModel
.
So that it is possible to create compatible nested schemas and models with snake_case attributes but still have camelCase`d ones on the frontend.
Have you already tried using these 2 together, I don't immediately see a reason for conflict. But maybe I'm missing something.
All that the fastapi_camelcase library does is set 2 config variables: https://github.com/nf1s/fastapi-camelcase/blob/master/fastapi_camelcase/init.py
Maybe try something like:
from humps import camelize
from sqlalchemy_pydantic_orm import ORMBaseSchema
class MyBaseModel(ORMBaseSchema):
class Config(ORMBaseSchema.Config):
alias_generator = camelize
allow_population_by_field_name = True
Does this work? (Haven't tried it myself)
Have you already tried using these 2 together, I don't immediately see a reason for conflict.
It works. The point is, I missed something. Sorry for not answering earlier.