Add Dog schema

This commit is contained in:
Backend IM Bot 2025-03-26 21:06:40 +01:00
parent b1b9df2987
commit 9c7ee7157b

28
schemas/dog.py Normal file
View File

@ -0,0 +1,28 @@
from pydantic import BaseModel, Field
from typing import Optional
# Base schema
class DogBase(BaseModel):
name: str = Field(..., description="Name of the dog")
breed: str = Field(..., description="Breed of the dog")
age: int = Field(..., gt=0, description="Age of the dog in years")
owner_id: Optional[str] = Field(None, description="ID of the owner (foreign key)")
# Schema for creating a new Dog
class DogCreate(DogBase):
pass
# Schema for Dog responses
class Dog(DogBase):
id: int
class Config:
orm_mode = True
schema_extra = {
"example": {
"name": "Buddy",
"breed": "Labrador",
"age": 5,
"owner_id": "user123"
}
}