Skip to content

Instantly share code, notes, and snippets.

@MartinThoma
Created November 1, 2020 21:12
Show Gist options
  • Save MartinThoma/3a6ed78f6f8140a8ccebc20b08d49e0b to your computer and use it in GitHub Desktop.
Save MartinThoma/3a6ed78f6f8140a8ccebc20b08d49e0b to your computer and use it in GitHub Desktop.
class Person(BaseModel):
id: PersonId
name: str
bank_account: Decimal
birthdate: datetime.date
friends: Optional[List[PersonId]] = None
class Config:
allow_population_by_field_name = True
# We use the Python attribute 'bank_account',
# but read/write the JSON 'bankAccount'
fields = {"bank_account": "bankAccount"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment