25 lines
898 B
Python
25 lines
898 B
Python
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 |