mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
17b5ff42c1
* renaming docs examples * tweaks
16 lines
361 B
Python
16 lines
361 B
Python
from pydantic import BaseModel
|
|
|
|
def to_camel(string: str) -> str:
|
|
return ''.join(word.capitalize() for word in string.split('_'))
|
|
|
|
class Voice(BaseModel):
|
|
name: str
|
|
language_code: str
|
|
|
|
class Config:
|
|
alias_generator = to_camel
|
|
|
|
voice = Voice(Name='Filiz', LanguageCode='tr-TR')
|
|
print(voice.language_code)
|
|
print(voice.dict(by_alias=True))
|