File size: 860 Bytes
ae09122 72194b1 f3f0c98 dd32be5 ae09122 79099e6 72194b1 79099e6 ae09122 dd32be5 ae09122 72194b1 ae09122 6863a84 ae09122 dd32be5 ae09122 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # app/routers/schema.py
from fastapi import APIRouter, Depends, Query
from app.deps import verify_api_key
from typing import Dict
from app.schemas.org_schema import OrgSchema
router = APIRouter(prefix="/api/v1/schema", tags=["schema"])
@router.get("/discover")
async def discover_schema(
org_id: str = Query(..., description="Organization ID"),
api_key: str = Depends(verify_api_key),
):
"""Return column mappings for this org"""
schema = OrgSchema(org_id)
return schema.get_mapping()
@router.post("/override")
async def override_schema(
mapping: Dict[str, str],
org_id: str = Query(..., description="Organization ID"),
api_key: str = Depends(verify_api_key),
):
"""Allow manual column mapping override"""
schema = OrgSchema(org_id)
schema.save_mapping(mapping)
return {"status": "saved", "mapping": mapping} |