feat: Add Book schemas
This commit is contained in:
parent
953446bd63
commit
3f302f2a17
26
schemas/book.py
Normal file
26
schemas/book.py
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user