Files
multi-seal-mail/server/app/api/v1/system.py
2026-06-08 15:57:11 +02:00

26 lines
774 B
Python

from __future__ import annotations
import json
from pathlib import Path
from typing import Any
from fastapi import APIRouter, Depends
from app.auth.dependencies import ApiPrincipal, require_scope
router = APIRouter(prefix="/schemas", tags=["schemas"])
@router.get("/campaign")
def get_campaign_schema(
principal: ApiPrincipal = Depends(require_scope("campaign:read")),
) -> dict[str, Any]:
"""Return the authoritative campaign JSON Schema used by the backend.
The WebUI can fetch this instead of carrying a stale copy. A future UI
schema can be served alongside this endpoint.
"""
schema_path = Path(__file__).resolve().parents[2] / "mailer" / "schemas" / "campaign.schema.json"
return json.loads(schema_path.read_text(encoding="utf-8"))