MCPcopy
hub / github.com/pydantic/pydantic / int_schema

Method int_schema

pydantic/json_schema.py:660–672  ·  view source on GitHub ↗

Generates a JSON schema that matches an int value. Args: schema: The core schema. Returns: The generated JSON schema.

(self, schema: core_schema.IntSchema)

Source from the content-addressed store, hash-verified

658 return {'type': 'boolean'}
659
660 def int_schema(self, schema: core_schema.IntSchema) -> JsonSchemaValue:
661 """Generates a JSON schema that matches an int value.
662
663 Args:
664 schema: The core schema.
665
666 Returns:
667 The generated JSON schema.
668 """
669 json_schema: dict[str, Any] = {'type': 'integer'}
670 self.update_with_validations(json_schema, schema, self.ValidationsMapping.numeric)
671 json_schema = {k: v for k, v in json_schema.items() if v not in {math.inf, -math.inf}}
672 return json_schema
673
674 def float_schema(self, schema: core_schema.FloatSchema) -> JsonSchemaValue:
675 """Generates a JSON schema that matches a float value.

Calls 2

itemsMethod · 0.45