feat: Add Book schemas
This commit is contained in:
parent
beb2a9d40f
commit
dc8fe6b7c8
25
schemas/book.py
Normal file
25
schemas/book.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
from pydantic import BaseModel, Field
|
||||||
|
from typing import Optional
|
||||||
|
from datetime import datetime
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
|
class BookBase(BaseModel):
|
||||||
|
title: str = Field(..., description="Title of the book")
|
||||||
|
author: str = Field(..., description="Author of the book")
|
||||||
|
description: Optional[str] = Field(None, description="Description of the book")
|
||||||
|
publisher: Optional[str] = Field(None, description="Publisher of the book")
|
||||||
|
publication_year: Optional[int] = Field(None, description="Year of publication")
|
||||||
|
isbn: str = Field(..., description="ISBN of the book")
|
||||||
|
pages: Optional[int] = Field(None, description="Number of pages")
|
||||||
|
language: Optional[str] = Field(None, description="Language of the book")
|
||||||
|
|
||||||
|
class BookCreate(BookBase):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class BookSchema(BookBase):
|
||||||
|
id: UUID
|
||||||
|
created_at: datetime
|
||||||
|
updated_at: datetime
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
orm_mode = True
|
Loading…
x
Reference in New Issue
Block a user