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.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
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.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
maybe_ref_json_schema
|
JsonSchemaValue
|
A JsonSchemaValue which may be a |
必需 |
引发:
| 类型 | 描述 |
|---|---|
LookupError
|
If the ref is not found. |
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
JsonSchemaValue |
JsonSchemaValue
|
A JsonSchemaValue that has no |
源代码位于: .venv/lib/python3.13/site-packages/pydantic/annotated_handlers.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
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!
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
source_type
|
Any
|
The input type. |
必需 |
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
CoreSchema |
CoreSchema
|
The |
源代码位于: .venv/lib/python3.13/site-packages/pydantic/annotated_handlers.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
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.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
maybe_ref_schema
|
CoreSchema
|
A |
必需 |
引发:
| 类型 | 描述 |
|---|---|
LookupError
|
If the |
返回:
| 类型 | 描述 |
|---|---|
CoreSchema
|
A concrete |
源代码位于: .venv/lib/python3.13/site-packages/pydantic/annotated_handlers.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |