mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 14:50:19 +00:00
f55515820a
* renaming .json -> .model_dump_json * renaming .dict -> .model_dump * renaming .__fields__ -> .model_fields * renaming .schema -> .model_json_schema * renaming .construct -> .model_construct * renaming .parse_obj -> .model_validate * make linters happy * add changes md-file Co-authored-by: Samuel Colvin <s@muelcolvin.com>
19 lines
370 B
Python
19 lines
370 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.model_dump(by_alias=True))
|