from pydantic import BaseModel, Field from typing import Optional from uuid import UUID class BookBase(BaseModel): title: str = Field(..., min_length=1, max_length=200, description="Book title") description: Optional[str] = Field(None, description="Book description") isbn: str = Field(..., description="Book ISBN number") publication_year: int = Field(..., ge=1000, le=9999, description="Year of publication") author_id: str = Field(..., description="ID of the book's author") class BookCreate(BookBase): class Config: schema_extra = { "example": { "title": "The Great Gatsby", "description": "A novel by F. Scott Fitzgerald", "isbn": "978-0743273565", "publication_year": 1925, "author_id": "author_uuid_here" } } class Book(BookBase): id: UUID class Config: orm_mode = True schema_extra = { "example": { "id": "550e8400-e29b-41d4-a716-446655440000", "title": "The Great Gatsby", "description": "A novel by F. Scott Fitzgerald", "isbn": "978-0743273565", "publication_year": 1925, "author_id": "author_uuid_here" } }