MCPcopy
hub / github.com/pydantic/pydantic / lax_or_strict_schema

Method lax_or_strict_schema

pydantic/json_schema.py:1423–1440  ·  view source on GitHub ↗

Generates a JSON schema that matches a schema that allows values matching either the lax schema or the strict schema. Args: schema: The core schema. Returns: The generated JSON schema.

(self, schema: core_schema.LaxOrStrictSchema)

Source from the content-addressed store, hash-verified

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
1425 strict schema.
1426
1427 Args:
1428 schema: The core schema.
1429
1430 Returns:
1431 The generated JSON schema.
1432 """
1433 # TODO: Need to read the default value off of model config or whatever
1434 use_strict = schema.get('strict', False) # TODO: replace this default False
1435 # If your JSON schema fails to generate it is probably
1436 # because one of the following two branches failed.
1437 if use_strict:
1438 return self.generate_inner(schema['strict_schema'])
1439 else:
1440 return self.generate_inner(schema['lax_schema'])
1441
1442 def json_or_python_schema(self, schema: core_schema.JsonOrPythonSchema) -> JsonSchemaValue:
1443 """Generates a JSON schema that matches a schema that allows values matching either the JSON schema or the

Callers 15

_ip_schemaMethod · 0.80
_path_schemaMethod · 0.80
_deque_schemaMethod · 0.80
_mapping_schemaMethod · 0.80
_fraction_schemaMethod · 0.80
test_lax_or_strictFunction · 0.80
test_lax_or_strictFunction · 0.80

Calls 2

generate_innerMethod · 0.95
getMethod · 0.45

Tested by 10

test_lax_or_strictFunction · 0.64
test_lax_or_strictFunction · 0.64
test_enumFunction · 0.64
pydantic_validatorMethod · 0.64
pydantic_validatorMethod · 0.64