Skip to main content
Pydantic Docs
current

Search documentation

Type to search this documentation.

On this pageOverview

Annotated Handlers

Type annotations to use with __get_pydantic_core_schema__ and __get_pydantic_json_schema__.

Handler to call into the next JSON schema generation function.

Json schema mode, can be validation or serialization.

Type: JsonSchemaMode

Python
def resolve_ref_schema(maybe_ref_json_schema: JsonSchemaValue, /) -> JsonSchemaValue

Get the real schema for a {"$ref": ...} schema. If the schema given is not a $ref schema, it will be returned as is. This means you don't have to check before calling this function.

JsonSchemaValue -- A JsonSchemaValue that has no $ref.

maybe_ref_json_schema : JsonSchemaValue

A JsonSchemaValue which may be a $ref schema.

  • LookupError -- If the ref is not found.

Handler to call into the next CoreSchema schema generation function.

Get the name of the closest field to this validator.

Type: str | None

Python
def generate_schema(source_type: Any, /) -> core_schema.CoreSchema

Generate a schema unrelated to the current context. Use this function if e.g. you are handling schema generation for a sequence and want to generate a schema for its items. Otherwise, you may end up doing something like applying a min_length constraint that was intended for the sequence itself to its items!

core_schema.CoreSchema -- The pydantic-core CoreSchema generated.

source_type : Any

The input type.

Python
def resolve_ref_schema(
    maybe_ref_schema: core_schema.CoreSchema,
    /,
) -> core_schema.CoreSchema

Get the real schema for a definition-ref schema. If the schema given is not a definition-ref schema, it will be returned as is. This means you don't have to check before calling this function.

core_schema.CoreSchema -- A concrete CoreSchema.

maybe_ref_schema : core_schema.CoreSchema

A CoreSchema, ref-based or not.

  • LookupError -- If the ref is not found.
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu