MCPcopy
hub / github.com/pydantic/pydantic / generator_schema

Method generator_schema

pydantic/json_schema.py:1056–1068  ·  view source on GitHub ↗

Returns a JSON schema that represents the provided GeneratorSchema. Args: schema: The schema. Returns: The generated JSON schema.

(self, schema: core_schema.GeneratorSchema)

Source from the content-addressed store, hash-verified

1054 return json_schema
1055
1056 def generator_schema(self, schema: core_schema.GeneratorSchema) -> JsonSchemaValue:
1057 """Returns a JSON schema that represents the provided GeneratorSchema.
1058
1059 Args:
1060 schema: The schema.
1061
1062 Returns:
1063 The generated JSON schema.
1064 """
1065 items_schema = {} if 'items_schema' not in schema else self.generate_inner(schema['items_schema'])
1066 json_schema = {'type': 'array', 'items': items_schema}
1067 self.update_with_validations(json_schema, schema, self.ValidationsMapping.array)
1068 return json_schema
1069
1070 def dict_schema(self, schema: core_schema.DictSchema) -> JsonSchemaValue:
1071 """Generates a JSON schema that matches a dict schema.

Callers 8

_iterable_schemaMethod · 0.80
test_generator_any_iterFunction · 0.80
test_generator_anyFunction · 0.80
test_generator_intFunction · 0.80
test_includeFunction · 0.80
test_generator_too_longFunction · 0.80
test_generator_too_shortFunction · 0.80

Calls 2

generate_innerMethod · 0.95

Tested by 7

test_generator_any_iterFunction · 0.64
test_generator_anyFunction · 0.64
test_generator_intFunction · 0.64
test_includeFunction · 0.64
test_generator_too_longFunction · 0.64
test_generator_too_shortFunction · 0.64