Add User schema

This commit is contained in:
Backend IM Bot 2025-03-27 16:40:07 +00:00
parent 89a0eabcfb
commit 14ca00741a

42
schemas/user.py Normal file
View File

@ -0,0 +1,42 @@
from pydantic import BaseModel, Field
from typing import Optional
from decimal import Decimal
class UserBase(BaseModel):
address: str = Field(..., description="Property address")
square_footage: float = Field(..., gt=0, description="Square footage of the property")
bedrooms: int = Field(..., gt=0, description="Number of bedrooms")
bathrooms: float = Field(..., gt=0, description="Number of bathrooms")
year_built: int = Field(..., gt=1800, lt=2100, description="Year the property was built")
property_type: str = Field(..., description="Type of property")
price: float = Field(..., gt=0, description="Property price")
is_available: bool = Field(default=True, description="Property availability status")
description: Optional[str] = Field(None, description="Property description")
garage_spaces: int = Field(default=0, ge=0, description="Number of garage spaces")
lot_size: Optional[float] = Field(None, gt=0, description="Size of the lot")
status: str = Field(default="available", description="Current status of the property")
class UserCreate(UserBase):
class Config:
schema_extra = {
"example": {
"address": "123 Main St",
"square_footage": 2000.0,
"bedrooms": 3,
"bathrooms": 2.5,
"year_built": 2000,
"property_type": "Single Family Home",
"price": 350000.0,
"is_available": True,
"description": "Beautiful home in quiet neighborhood",
"garage_spaces": 2,
"lot_size": 5000.0,
"status": "available"
}
}
class UserResponse(UserBase):
id: int = Field(..., description="Unique identifier for the property")
class Config:
orm_mode = True