MCPcopy
hub / github.com/pydantic/pydantic / chain_schema

Method chain_schema

pydantic/json_schema.py:1408–1421  ·  view source on GitHub ↗

Generates a JSON schema that matches a core_schema.ChainSchema. When generating a schema for validation, we return the validation JSON schema for the first step in the chain. For serialization, we return the serialization JSON schema for the last step in the chain. Args:

(self, schema: core_schema.ChainSchema)

Source from the content-addressed store, hash-verified

1406 return openapi_discriminator
1407
1408 def chain_schema(self, schema: core_schema.ChainSchema) -> JsonSchemaValue:
1409 """Generates a JSON schema that matches a core_schema.ChainSchema.
1410
1411 When generating a schema for validation, we return the validation JSON schema for the first step in the chain.
1412 For serialization, we return the serialization JSON schema for the last step in the chain.
1413
1414 Args:
1415 schema: The core schema.
1416
1417 Returns:
1418 The generated JSON schema.
1419 """
1420 step_index = 0 if self.mode == 'validation' else -1 # use first step for validation, last for serialization
1421 return self.generate_inner(schema['steps'][step_index])
1422
1423 def lax_or_strict_schema(self, schema: core_schema.LaxOrStrictSchema) -> JsonSchemaValue:
1424 """Generates a JSON schema that matches a schema that allows values matching either the lax schema or the

Callers 15

_deque_schemaMethod · 0.80
_mapping_schemaMethod · 0.80
_sequence_schemaMethod · 0.80
_hashable_schemaMethod · 0.80
apply_known_metadataFunction · 0.80
_apply_stepFunction · 0.80
_apply_parseFunction · 0.80
test_chain_schemaFunction · 0.80
test_chainFunction · 0.80
test_chainFunction · 0.80

Calls 1

generate_innerMethod · 0.95

Tested by 11

test_chain_schemaFunction · 0.64
test_chainFunction · 0.64
test_chainFunction · 0.64
test_chain_manyFunction · 0.64
test_chain_errorFunction · 0.64
test_flattenFunction · 0.64
test_chain_emptyFunction · 0.64
test_chain_oneFunction · 0.64
test_chain_listFunction · 0.64
test_chain_two_functionsFunction · 0.64