Add Dog schema
This commit is contained in:
parent
56873c53b0
commit
add609de32
@ -1,46 +1,38 @@
|
|||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from datetime import datetime
|
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
class DogBase(BaseModel):
|
class DogBase(BaseModel):
|
||||||
breed_name: str = Field(..., min_length=1, max_length=100, description="Name of the dog breed")
|
name: str = Field(..., min_length=1, max_length=50, description="Dog's name")
|
||||||
origin: str = Field(..., description="Origin/country of the breed")
|
breed: str = Field(..., min_length=1, max_length=100, description="Dog's breed")
|
||||||
size: str = Field(..., description="Size category of the breed")
|
age: Optional[int] = Field(None, ge=0, le=30, description="Dog's age in years")
|
||||||
temperament: str = Field(..., description="Temperament characteristics")
|
color: Optional[str] = Field(None, max_length=50, description="Dog's color")
|
||||||
life_span: str = Field(..., description="Average life span of the breed")
|
weight: Optional[float] = Field(None, gt=0, description="Dog's weight in kg")
|
||||||
description: str = Field(..., description="Detailed description of the breed")
|
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 DogCreate(DogBase):
|
||||||
class Config:
|
class Config:
|
||||||
schema_extra = {
|
schema_extra = {
|
||||||
"example": {
|
"example": {
|
||||||
"breed_name": "Labrador Retriever",
|
"name": "Max",
|
||||||
"origin": "Canada",
|
"breed": "Golden Retriever",
|
||||||
"size": "Large",
|
"age": 3,
|
||||||
"temperament": "Friendly, Active, Outgoing",
|
"color": "Golden",
|
||||||
"life_span": "10-12 years",
|
"weight": 30.5,
|
||||||
"description": "The Labrador Retriever is one of the most popular dog breeds in the world."
|
"is_vaccinated": True,
|
||||||
|
"microchip_number": "123456789012",
|
||||||
|
"gender": "Male",
|
||||||
|
"is_neutered": True,
|
||||||
|
"description": "Friendly and energetic dog"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Dog(DogBase):
|
class Dog(DogBase):
|
||||||
id: UUID
|
id: UUID
|
||||||
created_at: datetime
|
|
||||||
updated_at: datetime
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
orm_mode = True
|
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"
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user