mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
23 lines
529 B
Python
23 lines
529 B
Python
from pydantic import BaseModel, Field
|
|
|
|
|
|
class Voice(BaseModel):
|
|
name: str = Field(None, alias='ActorName')
|
|
language_code: str = None
|
|
mood: str = None
|
|
|
|
|
|
class Character(Voice):
|
|
act: int = 1
|
|
|
|
class Config:
|
|
fields = {'language_code': 'lang'}
|
|
|
|
@classmethod
|
|
def alias_generator(cls, string: str) -> str:
|
|
# this is the same as `alias_generator = to_camel` above
|
|
return ''.join(word.capitalize() for word in string.split('_'))
|
|
|
|
|
|
print(Character.schema(by_alias=True))
|