Add Book schema
This commit is contained in:
parent
bba7849e37
commit
0d0cdcaec2
@ -6,8 +6,11 @@ class BookBase(BaseModel):
|
|||||||
title: str = Field(..., min_length=1, max_length=200, description="Book title")
|
title: str = Field(..., min_length=1, max_length=200, description="Book title")
|
||||||
description: Optional[str] = Field(None, description="Book description")
|
description: Optional[str] = Field(None, description="Book description")
|
||||||
isbn: str = Field(..., description="Book ISBN number")
|
isbn: str = Field(..., description="Book ISBN number")
|
||||||
publication_year: int = Field(..., ge=1000, le=9999, description="Year of publication")
|
|
||||||
author_id: str = Field(..., description="ID of the book's author")
|
author_id: str = Field(..., description="ID of the book's author")
|
||||||
|
publication_year: int = Field(..., ge=1000, le=2100, description="Year of publication")
|
||||||
|
pages: int = Field(..., gt=0, description="Number of pages")
|
||||||
|
genre: str = Field(..., description="Book genre")
|
||||||
|
publisher: str = Field(..., description="Book publisher")
|
||||||
|
|
||||||
class BookCreate(BookBase):
|
class BookCreate(BookBase):
|
||||||
class Config:
|
class Config:
|
||||||
@ -16,8 +19,11 @@ class BookCreate(BookBase):
|
|||||||
"title": "The Great Gatsby",
|
"title": "The Great Gatsby",
|
||||||
"description": "A novel by F. Scott Fitzgerald",
|
"description": "A novel by F. Scott Fitzgerald",
|
||||||
"isbn": "978-0743273565",
|
"isbn": "978-0743273565",
|
||||||
|
"author_id": "author_uuid",
|
||||||
"publication_year": 1925,
|
"publication_year": 1925,
|
||||||
"author_id": "author_uuid_here"
|
"pages": 180,
|
||||||
|
"genre": "Fiction",
|
||||||
|
"publisher": "Scribner"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +38,10 @@ class Book(BookBase):
|
|||||||
"title": "The Great Gatsby",
|
"title": "The Great Gatsby",
|
||||||
"description": "A novel by F. Scott Fitzgerald",
|
"description": "A novel by F. Scott Fitzgerald",
|
||||||
"isbn": "978-0743273565",
|
"isbn": "978-0743273565",
|
||||||
|
"author_id": "author_uuid",
|
||||||
"publication_year": 1925,
|
"publication_year": 1925,
|
||||||
"author_id": "author_uuid_here"
|
"pages": 180,
|
||||||
|
"genre": "Fiction",
|
||||||
|
"publisher": "Scribner"
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user