MCPcopy
hub / github.com/pydantic/pydantic / function_before_schema

Method function_before_schema

pydantic/json_schema.py:1118–1130  ·  view source on GitHub ↗

Generates a JSON schema that matches a function-before schema. Args: schema: The core schema. Returns: The generated JSON schema.

(self, schema: core_schema.BeforeValidatorFunctionSchema)

Source from the content-addressed store, hash-verified

1116 return json_schema
1117
1118 def function_before_schema(self, schema: core_schema.BeforeValidatorFunctionSchema) -> JsonSchemaValue:
1119 """Generates a JSON schema that matches a function-before schema.
1120
1121 Args:
1122 schema: The core schema.
1123
1124 Returns:
1125 The generated JSON schema.
1126 """
1127 if self.mode == 'validation' and (input_schema := schema.get('json_schema_input_schema')):
1128 return self.generate_inner(input_schema)
1129
1130 return self.generate_inner(schema['schema'])
1131
1132 def function_after_schema(self, schema: core_schema.AfterValidatorFunctionSchema) -> JsonSchemaValue:
1133 """Generates a JSON schema that matches a function-after schema.

Callers

nothing calls this directly

Calls 2

generate_innerMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected