27 lines
1.0 KiB
Python
27 lines
1.0 KiB
Python
from pydantic import BaseModel, Field
|
|
from typing import Optional, List
|
|
from datetime import datetime
|
|
import uuid
|
|
|
|
class BookBase(BaseModel):
|
|
title: str = Field(..., description="Book title")
|
|
description: Optional[str] = Field(None, description="Book description")
|
|
year_published: int = Field(..., description="Year the book was published")
|
|
|
|
class BookCreate(BookBase):
|
|
author_ids: List[uuid.UUID] = Field(..., description="List of author IDs")
|
|
|
|
class BookUpdate(BookBase):
|
|
title: Optional[str] = Field(None, description="Book title")
|
|
description: Optional[str] = Field(None, description="Book description")
|
|
year_published: Optional[int] = Field(None, description="Year the book was published")
|
|
author_ids: Optional[List[uuid.UUID]] = Field(None, description="List of author IDs")
|
|
|
|
class BookSchema(BookBase):
|
|
id: uuid.UUID
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
author_ids: List[uuid.UUID] = Field(..., description="List of author IDs")
|
|
|
|
class Config:
|
|
orm_mode = True |