49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
from pydantic import BaseModel, Field
|
|
from typing import Optional
|
|
|
|
class SchoolBase(BaseModel):
|
|
name: str = Field(..., description="School name", index=True)
|
|
address: str = Field(..., description="School address")
|
|
capacity: int = Field(..., gt=0, description="Total capacity")
|
|
storage_type: str = Field(..., description="Type of storage")
|
|
temperature_controlled: bool = Field(False, description="Temperature control status")
|
|
security_level: str = Field(..., description="Security level")
|
|
is_active: bool = Field(True, description="Active status")
|
|
square_footage: int = Field(..., gt=0, description="Total square footage")
|
|
available_space: int = Field(..., ge=0, description="Available space")
|
|
|
|
class SchoolCreate(SchoolBase):
|
|
class Config:
|
|
schema_extra = {
|
|
"example": {
|
|
"name": "Central School",
|
|
"address": "123 Education St",
|
|
"capacity": 1000,
|
|
"storage_type": "Standard",
|
|
"temperature_controlled": False,
|
|
"security_level": "Medium",
|
|
"is_active": True,
|
|
"square_footage": 50000,
|
|
"available_space": 20000
|
|
}
|
|
}
|
|
|
|
class School(SchoolBase):
|
|
id: int = Field(..., description="School ID")
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
schema_extra = {
|
|
"example": {
|
|
"id": 1,
|
|
"name": "Central School",
|
|
"address": "123 Education St",
|
|
"capacity": 1000,
|
|
"storage_type": "Standard",
|
|
"temperature_controlled": False,
|
|
"security_level": "Medium",
|
|
"is_active": True,
|
|
"square_footage": 50000,
|
|
"available_space": 20000
|
|
}
|
|
} |