from pydantic import BaseModel, Field from typing import Optional from datetime import datetime from uuid import UUID class MessageBase(BaseModel): content: str = Field(..., min_length=1, description="Message content") sender_id: UUID = Field(..., description="ID of the message sender") receiver_id: UUID = Field(..., description="ID of the message receiver") class MessageCreate(MessageBase): class Config: schema_extra = { "example": { "content": "Hello, how are you?", "sender_id": "123e4567-e89b-12d3-a456-426614174000", "receiver_id": "987fcdeb-51a2-3b4c-9d0e-142357468000" } } class Message(MessageBase): id: UUID is_read: bool = False created_at: datetime updated_at: datetime class Config: orm_mode = True schema_extra = { "example": { "id": "123e4567-e89b-12d3-a456-426614174000", "content": "Hello, how are you?", "sender_id": "123e4567-e89b-12d3-a456-426614174000", "receiver_id": "987fcdeb-51a2-3b4c-9d0e-142357468000", "is_read": False, "created_at": "2023-01-01T00:00:00", "updated_at": "2023-01-01T00:00:00" } }