From efa22ff5463b105aa8fcac48d9220e1bdf032236 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Wed, 26 Mar 2025 18:35:28 +0100 Subject: [PATCH] Add Book schema --- schemas/book.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 schemas/book.py diff --git a/schemas/book.py b/schemas/book.py new file mode 100644 index 0000000..d2b071e --- /dev/null +++ b/schemas/book.py @@ -0,0 +1,32 @@ +from pydantic import BaseModel, Field +from datetime import datetime +from typing import Optional + +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: Optional[int] = Field(None, description="Number of pages") + published_date: Optional[datetime] = Field(None, description="Publication date") + genre_id: str = Field(..., description="ID of the book genre") + + class Config: + schema_extra = { + "example": { + "title": "The Great Gatsby", + "author": "F. Scott Fitzgerald", + "description": "A classic American novel about the Roaring Twenties.", + "page_count": 180, + "published_date": "1925-04-10T00:00:00", + "genre_id": "c1a2b3c4-d5e6-f7g8-h9i0-j1k2l3m4n5o6" + } + } + +class BookCreate(BookBase): + pass + +class BookResponse(BookBase): + id: str + + class Config: + orm_mode = True \ No newline at end of file