26 lines
652 B
Python
26 lines
652 B
Python
from pydantic import BaseModel, Field
|
|
|
|
class PenBase(BaseModel):
|
|
name: str = Field(..., description="Name of the pen")
|
|
color: str = Field(..., description="Color of the pen")
|
|
brand: str = Field(..., description="Brand of the pen")
|
|
price: int = Field(..., gt=0, description="Price of the pen")
|
|
|
|
class Config:
|
|
schema_extra = {
|
|
"example": {
|
|
"name": "BIC Cristal",
|
|
"color": "Blue",
|
|
"brand": "BIC",
|
|
"price": 2
|
|
}
|
|
}
|
|
|
|
class PenCreate(PenBase):
|
|
pass
|
|
|
|
class PenResponse(PenBase):
|
|
id: int
|
|
|
|
class Config:
|
|
orm_mode = True |