From c2515c776bf41ff47e4fd567b15cbcaef4b980e2 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Thu, 27 Mar 2025 03:19:16 -0500 Subject: [PATCH] Add Bird schema --- schemas/bird.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 schemas/bird.py diff --git a/schemas/bird.py b/schemas/bird.py new file mode 100644 index 0000000..907b3b5 --- /dev/null +++ b/schemas/bird.py @@ -0,0 +1,27 @@ +from pydantic import BaseModel, Field + +# Base schema +class BirdBase(BaseModel): + name: str = Field(..., description="Name of the bird") + species: str = Field(..., description="Species of the bird") + description: str | None = Field(None, description="Description of the bird") + age: int | None = Field(None, description="Age of the bird") + + class Config: + schema_extra = { + "example": { + "name": "Tweety", + "species": "Canary", + "description": "A cheerful little bird", + "age": 2 + } + } + +# Schema for creating a new bird +class BirdCreate(BirdBase): + pass + +# Schema for bird responses +class Bird(BirdBase): + class Config: + orm_mode = True \ No newline at end of file