Skip to main content

JsonApiResourceBase

Base class for JSON:API resource responses. This follows the JSON:API specification (https://jsonapi.org/) for consistent resource representation across the API.

Fields

FieldTypeRequiredDefaultDescription
idstrPydanticUndefinedUnique resource identifier
typestrPydanticUndefinedResource type identifier

Usage Example

from credoai.models import JsonApiResourceBase

# Create a new instance
model = JsonApiResourceBase(
id="example_value", # Unique resource identifier
type="example_value", # Resource type identifier
)

# Convert to dictionary
model_dict = model.model_dump()
print(model_dict)

# Create from dictionary
data = {
"id": "example_value",
"type": "example_value",
}
model_from_dict = JsonApiResourceBase(**data)

JSON Schema

{
"type": "object",
"title": "JsonApiResourceBase",
"description": "Base class for JSON:API resource responses.
This follows the JSON:API specification (https://jsonapi.org/) for
consistent resource representation across the API.",
"properties": {
"id": {
"type": "str",
"description": "Unique resource identifier"
},
"type": {
"type": "str",
"description": "Resource type identifier"
}
},
"required": ["id", "type"]
}