From 9c7ee7157bcab6f3d971bd3c7d848864a902bf14 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Wed, 26 Mar 2025 21:06:40 +0100 Subject: [PATCH] Add Dog schema --- schemas/dog.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 schemas/dog.py diff --git a/schemas/dog.py b/schemas/dog.py new file mode 100644 index 0000000..982fe42 --- /dev/null +++ b/schemas/dog.py @@ -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" + } + } \ No newline at end of file