Custom Field wrapper that adds status to json_schema_extra. Args: default: The default value for the field status: Optional status indicator that gets added to json_schema_extra. - None: Stable. - "beta": Recommended for use per the latest documentation.
(default: Any = ...,
*,
status: Optional[Literal["prototype", "beta", "deprecated"]] = None,
**kwargs: Any)
| 66 | |
| 67 | |
| 68 | def Field(default: Any = ..., |
| 69 | *, |
| 70 | status: Optional[Literal["prototype", "beta", "deprecated"]] = None, |
| 71 | **kwargs: Any) -> Any: |
| 72 | """Custom Field wrapper that adds status to json_schema_extra. |
| 73 | |
| 74 | Args: |
| 75 | default: The default value for the field |
| 76 | status: Optional status indicator that gets added to json_schema_extra. |
| 77 | - None: Stable. |
| 78 | - "beta": Recommended for use per the latest documentation. |
| 79 | - "prototype": Not yet stable and subject to breaking changes; intended for experimentation only. |
| 80 | **kwargs: All other arguments passed to the original Pydantic Field |
| 81 | |
| 82 | Returns: |
| 83 | A Pydantic FieldInfo object with the status added to json_schema_extra if provided |
| 84 | """ |
| 85 | |
| 86 | if status is not None: |
| 87 | json_schema_extra = kwargs.get('json_schema_extra', {}) |
| 88 | if isinstance(json_schema_extra, dict): |
| 89 | json_schema_extra['status'] = status |
| 90 | else: |
| 91 | # If json_schema_extra is not a dict, create a new dict with the status |
| 92 | json_schema_extra = {'status': status} |
| 93 | kwargs['json_schema_extra'] = json_schema_extra |
| 94 | |
| 95 | return PydanticField(default, **kwargs) |
| 96 | |
| 97 | |
| 98 | class StrictBaseModel(BaseModel): |
no test coverage detected