16 lines
380 B
Python
16 lines
380 B
Python
"""Base schema with camelCase JSON serialization."""
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
|
|
def to_camel(s: str) -> str:
|
|
parts = s.split("_")
|
|
return parts[0] + "".join(p.capitalize() for p in parts[1:])
|
|
|
|
|
|
class CamelModel(BaseModel):
|
|
model_config = ConfigDict(
|
|
from_attributes=True,
|
|
alias_generator=to_camel,
|
|
populate_by_name=True,
|
|
)
|