Add Book schema
This commit is contained in:
parent
00cbc6a44d
commit
1cf90d0f00
@ -2,14 +2,13 @@ from pydantic import BaseModel, Field
|
||||
from typing import Optional
|
||||
|
||||
class BookBase(BaseModel):
|
||||
title: str = Field(..., description="Book title")
|
||||
author: str = Field(..., description="Book author")
|
||||
isbn: str = Field(..., description="Book ISBN number")
|
||||
publication_year: Optional[int] = Field(None, description="Year of publication")
|
||||
publisher: Optional[str] = Field(None, description="Book publisher")
|
||||
title: str = Field(..., min_length=1, description="Book title")
|
||||
author: str = Field(..., min_length=1, description="Book author")
|
||||
description: Optional[str] = Field(None, description="Book description")
|
||||
copies_available: int = Field(default=1, description="Number of copies available")
|
||||
is_available: bool = Field(default=True, description="Book availability status")
|
||||
isbn: str = Field(..., description="Book ISBN number")
|
||||
price: int = Field(..., gt=0, description="Book price")
|
||||
quantity: int = Field(0, ge=0, description="Available quantity")
|
||||
is_available: bool = Field(True, description="Book availability status")
|
||||
|
||||
class BookCreate(BookBase):
|
||||
class Config:
|
||||
@ -17,11 +16,10 @@ class BookCreate(BookBase):
|
||||
"example": {
|
||||
"title": "The Great Gatsby",
|
||||
"author": "F. Scott Fitzgerald",
|
||||
"description": "A story of decadence and excess",
|
||||
"isbn": "978-0743273565",
|
||||
"publication_year": 1925,
|
||||
"publisher": "Charles Scribner's Sons",
|
||||
"description": "A story of the fabulously wealthy Jay Gatsby",
|
||||
"copies_available": 5,
|
||||
"price": 999,
|
||||
"quantity": 50,
|
||||
"is_available": True
|
||||
}
|
||||
}
|
||||
@ -36,11 +34,10 @@ class Book(BookBase):
|
||||
"id": 1,
|
||||
"title": "The Great Gatsby",
|
||||
"author": "F. Scott Fitzgerald",
|
||||
"description": "A story of decadence and excess",
|
||||
"isbn": "978-0743273565",
|
||||
"publication_year": 1925,
|
||||
"publisher": "Charles Scribner's Sons",
|
||||
"description": "A story of the fabulously wealthy Jay Gatsby",
|
||||
"copies_available": 5,
|
||||
"price": 999,
|
||||
"quantity": 50,
|
||||
"is_available": True
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user