Annotated Handlers
Type annotations to use with __get_pydantic_core_schema__ and __get_pydantic_json_schema__.
GetJsonSchemaHandler ¶
Handler to call into the next JSON schema generation function.
Attributes:
| Name | Type | Description |
|---|---|---|
mode |
JsonSchemaMode
|
Json schema mode, can be |
resolve_ref_schema ¶
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
maybe_ref_json_schema |
JsonSchemaValue
|
A JsonSchemaValue which may be a |
required |
Raises:
| Type | Description |
|---|---|
LookupError
|
If the ref is not found. |
Returns:
| Name | Type | Description |
|---|---|---|
JsonSchemaValue |
JsonSchemaValue
|
A JsonSchemaValue that has no |
Source code in pydantic/annotated_handlers.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
GetCoreSchemaHandler ¶
Handler to call into the next CoreSchema schema generation function.
generate_schema ¶
generate_schema(source_type: Any) -> 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!
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_type |
Any
|
The input type. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
CoreSchema |
CoreSchema
|
The |
Source code in pydantic/annotated_handlers.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
resolve_ref_schema ¶
resolve_ref_schema(
maybe_ref_schema: CoreSchema,
) -> 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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
maybe_ref_schema |
CoreSchema
|
A |
required |
Raises:
| Type | Description |
|---|---|
LookupError
|
If the |
Returns:
| Type | Description |
|---|---|
CoreSchema
|
A concrete |
Source code in pydantic/annotated_handlers.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |