Add Dog schema

This commit is contained in:
Backend IM Bot 2025-03-26 13:27:56 +00:00
parent 56873c53b0
commit add609de32

View File

@ -1,46 +1,38 @@
from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime
from uuid import UUID
class DogBase(BaseModel):
breed_name: str = Field(..., min_length=1, max_length=100, description="Name of the dog breed")
origin: str = Field(..., description="Origin/country of the breed")
size: str = Field(..., description="Size category of the breed")
temperament: str = Field(..., description="Temperament characteristics")
life_span: str = Field(..., description="Average life span of the breed")
description: str = Field(..., description="Detailed description of the breed")
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")
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")
weight: Optional[float] = Field(None, gt=0, description="Dog's weight in kg")
is_vaccinated: bool = Field(default=False, description="Vaccination status")
microchip_number: str = Field(..., min_length=10, max_length=15, description="Unique microchip number")
gender: Optional[str] = Field(None, description="Dog's gender")
is_neutered: bool = Field(default=False, description="Neutering status")
description: Optional[str] = Field(None, max_length=500, description="Additional description")
class DogCreate(DogBase):
class Config:
schema_extra = {
"example": {
"breed_name": "Labrador Retriever",
"origin": "Canada",
"size": "Large",
"temperament": "Friendly, Active, Outgoing",
"life_span": "10-12 years",
"description": "The Labrador Retriever is one of the most popular dog breeds in the world."
"name": "Max",
"breed": "Golden Retriever",
"age": 3,
"color": "Golden",
"weight": 30.5,
"is_vaccinated": True,
"microchip_number": "123456789012",
"gender": "Male",
"is_neutered": True,
"description": "Friendly and energetic dog"
}
}
class Dog(DogBase):
id: UUID
created_at: datetime
updated_at: datetime
class Config:
orm_mode = True
schema_extra = {
"example": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"breed_name": "Labrador Retriever",
"origin": "Canada",
"size": "Large",
"temperament": "Friendly, Active, Outgoing",
"life_span": "10-12 years",
"description": "The Labrador Retriever is one of the most popular dog breeds in the world.",
"created_at": "2023-01-01T00:00:00",
"updated_at": "2023-01-01T00:00:00"
}
}