diff --git a/src/core/schemas.py b/src/core/schemas.py index 7e9d799..5c72d87 100644 --- a/src/core/schemas.py +++ b/src/core/schemas.py @@ -66,6 +66,7 @@ def keypass_to_response(kp: Keypass) -> KeypassResponse: # ── Gates ───────────────────────────────────────────────────────────────────── class GateResponse(BaseModel): + """Full gate response — admin use only.""" model_config = ConfigDict(from_attributes=True) id: int name: str @@ -75,6 +76,15 @@ class GateResponse(BaseModel): group_name: Optional[str] = None +class GatePublicResponse(BaseModel): + """Gate response for keypass users — no internal fields.""" + model_config = ConfigDict(from_attributes=True) + id: int + name: str + gate_type: str + group_name: Optional[str] = None + + class GateCreate(BaseModel): name: str gate_type: str # 'car' | 'pedestrian' diff --git a/src/routers/gates.py b/src/routers/gates.py index 0cb11af..ffcdb7b 100644 --- a/src/routers/gates.py +++ b/src/routers/gates.py @@ -8,7 +8,7 @@ from sqlalchemy.orm import Session from core.auth import decrypt_secret from core.database import ApiCredential, GateAccessLog, GateDB, Keypass, get_db from core.dependencies import require_admin, require_manager, require_keypass -from core.schemas import GateCreate, GateResponse +from core.schemas import GateCreate, GatePublicResponse, GateResponse from services.gates import call_open_gate router = APIRouter(tags=["gates"]) @@ -119,7 +119,7 @@ async def admin_open_gate( # ── User-facing gate routes ─────────────────────────────────────────────────── -@router.get("/api/gates", response_model=list[GateResponse]) +@router.get("/api/gates", response_model=list[GatePublicResponse]) async def list_gates( db: Session = Depends(get_db), _kp: Keypass = Depends(require_keypass) ):