refactor(api): scope uv to s2s-client and validate compatible responses
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
"""Validate service-owned response structure without rewriting the wire body."""
|
||||
|
||||
from typing import Any
|
||||
|
||||
from fastapi.responses import JSONResponse
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
def validated_json_response(
|
||||
content: Any,
|
||||
model: type[BaseModel],
|
||||
*,
|
||||
status_code: int = 200,
|
||||
) -> JSONResponse:
|
||||
model.model_validate(content)
|
||||
# model_dump would insert defaults, potentially coerce values, and reorder
|
||||
# fields. Keeping the original JSONResponse serialization is intentional.
|
||||
return JSONResponse(content=content, status_code=status_code)
|
||||
Reference in New Issue
Block a user