JsonApiResponse
Standard JSON:API response wrapper. Provides a consistent structure for all API responses following the JSON:API specification. Supports both single resources and collections.
Fields
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
data | ForwardRef('Union[JsonApiUseCaseResource, JsonApiUserResource, List[Union[JsonApiUseCaseResource, JsonApiUserResource]]]') | ✓ | PydanticUndefined | Primary response data |
included | ForwardRef('Optional[List[JsonApiResourceBase]]') | ✗ | None | Included resources for compound documents |
meta | ForwardRef('Optional[Dict[str, Any]]') | ✗ | None | Non-standard metadata about the response |
Usage Example
from credoai.models import JsonApiResponse
# Create a new instance
model = JsonApiResponse(
data=None, # Primary response data
)
# Convert to dictionary
model_dict = model.model_dump()
print(model_dict)
# Create from dictionary
data = {
"data": None,
}
model_from_dict = JsonApiResponse(**data)
JSON Schema
{
"type": "object",
"title": "JsonApiResponse",
"description": "Standard JSON:API response wrapper.
Provides a consistent structure for all API responses following the
JSON:API specification. Supports both single resources and collections.",
"properties": {
"data": {
"type": "forwardref('union[jsonapiusecaseresource, jsonapiuserresource, list[union[jsonapiusecaseresource, jsonapiuserresource]]]')",
"description": "Primary response data"
},
"included": {
"type": "forwardref('optional[list[jsonapiresourcebase]]')",
"description": "Included resources for compound documents"
},
"meta": {
"type": "forwardref('optional[dict[str, any]]')",
"description": "Non-standard metadata about the response"
}
},
"required": ["data", ]
}