MCPcopy
hub / github.com/pydantic/pydantic / resolve_ref_schema

Method resolve_ref_schema

pydantic/json_schema.py:1706–1724  ·  view source on GitHub ↗

Resolve a JsonSchemaValue to the non-ref schema if it is a $ref schema. Args: json_schema: The schema to resolve. Returns: The resolved schema. Raises: RuntimeError: If the schema reference can't be found in definitions.

(self, json_schema: JsonSchemaValue)

Source from the content-addressed store, hash-verified

1704 json_schema['deprecated'] = True
1705
1706 def resolve_ref_schema(self, json_schema: JsonSchemaValue) -> JsonSchemaValue:
1707 """Resolve a JsonSchemaValue to the non-ref schema if it is a $ref schema.
1708
1709 Args:
1710 json_schema: The schema to resolve.
1711
1712 Returns:
1713 The resolved schema.
1714
1715 Raises:
1716 RuntimeError: If the schema reference can't be found in definitions.
1717 """
1718 while '$ref' in json_schema:
1719 ref = json_schema['$ref']
1720 schema_to_update = self.get_schema_from_definitions(JsonRef(ref))
1721 if schema_to_update is None:
1722 raise RuntimeError(f'Cannot update undefined schema for $ref={ref}')
1723 json_schema = schema_to_update
1724 return json_schema
1725
1726 def model_fields_schema(self, schema: core_schema.ModelFieldsSchema) -> JsonSchemaValue:
1727 """Generates a JSON schema that matches a schema that defines a model's fields.

Calls 1