49 lines
931 B
Python
49 lines
931 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class TodoBase(BaseModel):
|
|
"""
|
|
Base schema for Todo items.
|
|
"""
|
|
title: str = Field(..., min_length=1, max_length=255)
|
|
description: Optional[str] = None
|
|
completed: bool = False
|
|
|
|
|
|
class TodoCreate(TodoBase):
|
|
"""
|
|
Schema for creating a new Todo item.
|
|
"""
|
|
pass
|
|
|
|
|
|
class TodoUpdate(BaseModel):
|
|
"""
|
|
Schema for updating an existing Todo item.
|
|
"""
|
|
title: Optional[str] = Field(None, min_length=1, max_length=255)
|
|
description: Optional[str] = None
|
|
completed: Optional[bool] = None
|
|
|
|
|
|
class TodoInDBBase(TodoBase):
|
|
"""
|
|
Base schema for Todo items in the database.
|
|
"""
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class Todo(TodoInDBBase):
|
|
"""
|
|
Schema for returning a Todo item.
|
|
"""
|
|
pass
|