Skip to main content

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

AttributeTypeDescription
typeLiteral['definitions']A fixed literal string used to identify this schema as a definitions-based schema.
schemaCoreSchemaThe primary core schema that utilizes the definitions provided in this structure.
definitionslist[CoreSchema]A list of core schemas that define reusable components or types referenced elsewhere.
metadatadict[str, Any]A dictionary for storing arbitrary additional information about the schema.
serializationSerSchemaConfiguration 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

TypeDescription
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

TypeDescription
CoreSchemaThe 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

TypeDescription
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

TypeDescription
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

TypeDescription
SerSchemaThe serialization schema settings applied to this definition.