Add Dog schema

This commit is contained in:
Backend IM Bot 2025-03-26 13:29:40 +00:00
parent 28e3e8b41d
commit 97fad86028

View File

@ -1,18 +1,15 @@
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
from typing import Optional from typing import Optional
from uuid import UUID
class DogBase(BaseModel): class DogBase(BaseModel):
name: str = Field(..., min_length=1, max_length=50, description="Dog's name") name: str = Field(..., min_length=1, max_length=50, description="Dog's name")
breed: str = Field(..., min_length=1, max_length=100, description="Dog's breed") breed: str = Field(..., min_length=1, max_length=50, description="Dog's breed")
age: Optional[int] = Field(None, ge=0, le=30, description="Dog's age in years") age: Optional[int] = Field(None, ge=0, le=30, description="Dog's age in years")
color: Optional[str] = Field(None, max_length=50, description="Dog's color") color: Optional[str] = Field(None, max_length=30, description="Dog's color")
weight: Optional[float] = Field(None, gt=0, description="Dog's weight in kg") weight: Optional[int] = Field(None, ge=0, le=200, description="Dog's weight in pounds")
is_vaccinated: bool = Field(default=False, description="Vaccination status") is_vaccinated: bool = Field(default=False, description="Vaccination status")
microchip_number: str = Field(..., min_length=10, max_length=15, description="Unique microchip number") owner_name: Optional[str] = Field(None, max_length=100, description="Owner's full name")
gender: Optional[str] = Field(None, description="Dog's gender") owner_contact: Optional[str] = Field(None, max_length=100, description="Owner's contact information")
is_neutered: bool = Field(default=False, description="Neutering status")
description: Optional[str] = Field(None, max_length=500, description="Additional description")
class DogCreate(DogBase): class DogCreate(DogBase):
class Config: class Config:
@ -22,17 +19,28 @@ class DogCreate(DogBase):
"breed": "Golden Retriever", "breed": "Golden Retriever",
"age": 3, "age": 3,
"color": "Golden", "color": "Golden",
"weight": 30.5, "weight": 70,
"is_vaccinated": True, "is_vaccinated": True,
"microchip_number": "123456789012", "owner_name": "John Doe",
"gender": "Male", "owner_contact": "+1-555-0123"
"is_neutered": True,
"description": "Friendly and energetic dog"
} }
} }
class Dog(DogBase): class Dog(DogBase):
id: UUID id: int = Field(..., description="The unique identifier for the dog")
class Config: class Config:
orm_mode = True orm_mode = True
schema_extra = {
"example": {
"id": 1,
"name": "Max",
"breed": "Golden Retriever",
"age": 3,
"color": "Golden",
"weight": 70,
"is_vaccinated": True,
"owner_name": "John Doe",
"owner_contact": "+1-555-0123"
}
}