CallableSchema
This class defines a schema for representing callable objects within a type system. It specifies the structure for identifying callables through a reference string, along with associated metadata and serialization instructions.
Attributes
| Attribute | Type | Description |
|---|---|---|
| type | Literal['callable'] | Discriminator field that must be set to the literal string 'callable' to identify this schema type. |
| ref | str | A string reference representing the import path or identifier of the callable to be executed. |
| metadata | dict[str, Any] | A dictionary of arbitrary key-value pairs used to store additional context or configuration for the callable. |
| serialization | SerSchema | Defines the serialization schema used to convert the callable or its return values into a serializable format. |
Methods
type()
def type() - > Literal['callable']
Identifies the schema type as a callable, ensuring the validator treats the input as a function or class constructor.
Returns
| Type | Description |
|---|---|
Literal['callable'] | The literal string 'callable' used for schema identification |
ref()
def ref() - > str
Specifies a unique reference string for the callable schema, typically used for recursive definitions or shared schema lookups.
Returns
| Type | Description |
|---|---|
str | The unique identifier string for this schema definition |
metadata()
def metadata() - > dict[str, Any]
Stores a dictionary of arbitrary metadata used to provide additional context or custom configuration for the callable.
Returns
| Type | Description |
|---|---|
dict[str, Any] | A mapping of metadata keys to their associated values |
serialization()
def serialization() - > SerSchema
Defines the serialization logic for the callable, determining how the function or class is converted to a serializable format.
Returns
| Type | Description |
|---|---|
SerSchema | The serialization schema configuration for the callable |