38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
from pydantic import BaseModel, Field
|
|
from typing import Optional
|
|
from uuid import UUID
|
|
|
|
class DogBase(BaseModel):
|
|
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": {
|
|
"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
|
|
|
|
class Config:
|
|
orm_mode = True |