Add Dog schema
This commit is contained in:
parent
172b4ba4b7
commit
d4f58a4c89
27
schemas/dog.py
Normal file
27
schemas/dog.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
from pydantic import BaseModel, Field
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
class DogBase(BaseModel):
|
||||||
|
name: str = Field(..., description="Dog's name")
|
||||||
|
breed: str = Field(..., description="Dog's breed")
|
||||||
|
age: int = Field(..., gt=0, description="Dog's age in years")
|
||||||
|
owner_id: Optional[str] = Field(None, description="ID of the dog's owner")
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"name": "Buddy",
|
||||||
|
"breed": "Labrador",
|
||||||
|
"age": 5,
|
||||||
|
"owner_id": "123e4567-e89b-12d3-a456-426614174000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DogCreate(DogBase):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class DogResponse(DogBase):
|
||||||
|
id: int
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
orm_mode = True
|
Loading…
x
Reference in New Issue
Block a user