23 lines
600 B
Python
23 lines
600 B
Python
from pydantic import BaseModel, Field
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
import uuid
|
|
|
|
class CarBase(BaseModel):
|
|
name: str = Field(..., description="Name of the car")
|
|
year: Optional[int] = Field(None, description="Year of the car")
|
|
|
|
class CarCreate(CarBase):
|
|
pass
|
|
|
|
class CarUpdate(CarBase):
|
|
name: Optional[str] = Field(None, description="Name of the car")
|
|
year: Optional[int] = Field(None, description="Year of the car")
|
|
|
|
class CarSchema(CarBase):
|
|
id: uuid.UUID
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
orm_mode = True |