MCPcopy
hub / github.com/pydantic/pydantic / field_is_present

Method field_is_present

pydantic/json_schema.py:1749–1765  ·  view source on GitHub ↗

Whether the field should be included in the generated JSON schema. Args: field: The schema for the field itself. Returns: `True` if the field should be included in the generated JSON schema, `False` otherwise.

(self, field: CoreSchemaField)

Source from the content-addressed store, hash-verified

1747 return json_schema
1748
1749 def field_is_present(self, field: CoreSchemaField) -> bool:
1750 """Whether the field should be included in the generated JSON schema.
1751
1752 Args:
1753 field: The schema for the field itself.
1754
1755 Returns:
1756 `True` if the field should be included in the generated JSON schema, `False` otherwise.
1757 """
1758 if self.mode == 'serialization':
1759 # If you still want to include the field in the generated JSON schema,
1760 # override this method and return True
1761 return not field.get('serialization_exclude')
1762 elif self.mode == 'validation':
1763 return True
1764 else:
1765 assert_never(self.mode)
1766
1767 def field_is_required(
1768 self,

Callers 3

typed_dict_schemaMethod · 0.95
model_fields_schemaMethod · 0.95
dataclass_args_schemaMethod · 0.95

Calls 2

assert_neverFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected