DefinitionsSchema
This class defines a schema for managing a collection of reusable core schema definitions. It requires a primary schema and a list of associated definitions, while supporting optional metadata and serialization configurations.
Attributes
| Attribute | Type | Description |
|---|---|---|
| type | Literal['definitions'] | A fixed literal string used to identify this schema as a definitions-based schema. |
| schema | CoreSchema | The primary core schema that utilizes the definitions provided in this structure. |
| definitions | list[CoreSchema] | A list of core schemas that define reusable components or types referenced elsewhere. |
| metadata | dict[str, Any] | A dictionary for storing arbitrary additional information about the schema. |
| serialization | SerSchema | Configuration settings that define how the schema should be handled during serialization processes. |
Methods
type()
def type() - > Literal['definitions']
Specifies the schema type identifier, which must be set to 'definitions' for this schema structure.
Returns
| Type | Description |
|---|---|
Literal['definitions'] | The literal string 'definitions' used for schema type discrimination. |
schema()
def schema() - > CoreSchema
Defines the primary core schema that utilizes the shared definitions provided in the definitions list.
Returns
| Type | Description |
|---|---|
CoreSchema | The main schema object that references the internal definitions. |
definitions()
def definitions() - > list[CoreSchema]
Provides a list of reusable core schemas that can be referenced by other parts of the schema to avoid duplication.
Returns
| Type | Description |
|---|---|
list[CoreSchema] | A collection of schema definitions available for internal reference. |
metadata()
def metadata() - > dict[str, Any]
Stores an extensible dictionary of custom data and configuration used to annotate the schema.
Returns
| Type | Description |
|---|---|
dict[str, Any] | A dictionary containing arbitrary metadata key-value pairs. |
serialization()
def serialization() - > SerSchema
Configures the serialization behavior and constraints for the schema when converting data to output formats.
Returns
| Type | Description |
|---|---|
SerSchema | The serialization schema settings applied to this definition. |