Add Dog schema
This commit is contained in:
parent
28e3e8b41d
commit
97fad86028
@ -1,18 +1,15 @@
|
||||
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")
|
||||
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")
|
||||
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")
|
||||
color: Optional[str] = Field(None, max_length=30, description="Dog's color")
|
||||
weight: Optional[int] = Field(None, ge=0, le=200, description="Dog's weight in pounds")
|
||||
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")
|
||||
owner_name: Optional[str] = Field(None, max_length=100, description="Owner's full name")
|
||||
owner_contact: Optional[str] = Field(None, max_length=100, description="Owner's contact information")
|
||||
|
||||
class DogCreate(DogBase):
|
||||
class Config:
|
||||
@ -22,17 +19,28 @@ class DogCreate(DogBase):
|
||||
"breed": "Golden Retriever",
|
||||
"age": 3,
|
||||
"color": "Golden",
|
||||
"weight": 30.5,
|
||||
"weight": 70,
|
||||
"is_vaccinated": True,
|
||||
"microchip_number": "123456789012",
|
||||
"gender": "Male",
|
||||
"is_neutered": True,
|
||||
"description": "Friendly and energetic dog"
|
||||
"owner_name": "John Doe",
|
||||
"owner_contact": "+1-555-0123"
|
||||
}
|
||||
}
|
||||
|
||||
class Dog(DogBase):
|
||||
id: UUID
|
||||
id: int = Field(..., description="The unique identifier for the dog")
|
||||
|
||||
class Config:
|
||||
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"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user