From 3f302f2a17cff3159c0e6b06bc942107f272a59a Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Fri, 11 Apr 2025 06:04:01 +0000 Subject: [PATCH] feat: Add Book schemas --- schemas/book.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 schemas/book.py diff --git a/schemas/book.py b/schemas/book.py new file mode 100644 index 0000000..3932ae3 --- /dev/null +++ b/schemas/book.py @@ -0,0 +1,26 @@ +from pydantic import BaseModel, Field +from typing import Optional +from datetime import datetime +from uuid import UUID + +# Base schema for Book +class BookBase(BaseModel): + title: str = Field(..., description="Book title") + author: str = Field(..., description="Book author") + description: Optional[str] = Field(None, description="Book description") + page_count: int = Field(..., gt=0, description="Number of pages in the book") + genre: str = Field(..., description="Book genre") + +# Schema for creating a new Book +class BookCreate(BookBase): + publisher_id: UUID = Field(..., description="ID of the book's publisher") + +# Schema for Book responses +class BookSchema(BookBase): + id: UUID + publisher_id: UUID + created_at: datetime + updated_at: datetime + + class Config: + orm_mode = True \ No newline at end of file