MCPcopy
hub / github.com/pydantic/pydantic / get_field_info_schema

Function get_field_info_schema

pydantic/v1/schema.py:200–219  ·  view source on GitHub ↗
(field: ModelField, schema_overrides: bool = False)

Source from the content-addressed store, hash-verified

198
199
200def get_field_info_schema(field: ModelField, schema_overrides: bool = False) -> Tuple[Dict[str, Any], bool]:
201 # If no title is explicitly set, we don't set title in the schema for enums.
202 # The behaviour is the same as `BaseModel` reference, where the default title
203 # is in the definitions part of the schema.
204 schema_: Dict[str, Any] = {}
205 if field.field_info.title or not lenient_issubclass(field.type_, Enum):
206 schema_['title'] = field.field_info.title or field.alias.title().replace('_', ' ')
207
208 if field.field_info.title:
209 schema_overrides = True
210
211 if field.field_info.description:
212 schema_['description'] = field.field_info.description
213 schema_overrides = True
214
215 if not field.required and field.default is not None and not is_callable_type(field.outer_type_):
216 schema_['default'] = encode_default(field.default)
217 schema_overrides = True
218
219 return schema_, schema_overrides
220
221
222def field_schema(

Callers 2

field_schemaFunction · 0.85
field_singleton_schemaFunction · 0.85

Calls 3

lenient_issubclassFunction · 0.90
is_callable_typeFunction · 0.90
encode_defaultFunction · 0.85

Tested by

no test coverage detected