30 行
994 B
Python
30 行
994 B
Python
"""Backend API contract export."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from backend.dto.common import ErrorCode
|
|
from backend.route_registry import permission_matrix, route_manifest
|
|
from backend.services.ui_service import API_BASE
|
|
|
|
|
|
class ContractService:
|
|
def get_contract(self) -> dict[str, Any]:
|
|
return {
|
|
"contract_version": "3.0",
|
|
"api_base": API_BASE,
|
|
"routes": route_manifest(),
|
|
"permissions": permission_matrix(),
|
|
"error_codes": [code.value for code in ErrorCode],
|
|
"response_shape": {
|
|
"success": {"ok": True, "data": {}, "warnings": [], "request_id": "req_..."},
|
|
"error": {
|
|
"ok": False,
|
|
"error_code": ErrorCode.VALIDATION_FAILED.value,
|
|
"message": "error message",
|
|
"details": {},
|
|
"request_id": "req_...",
|
|
},
|
|
},
|
|
}
|