Generate schema for an Annotated type, e.g. `Annotated[int, Field(...)]` or `Annotated[int, Gt(0)]`.
(self, annotated_type: Any)
| 2193 | ) |
| 2194 | |
| 2195 | def _annotated_schema(self, annotated_type: Any) -> core_schema.CoreSchema: |
| 2196 | """Generate schema for an Annotated type, e.g. `Annotated[int, Field(...)]` or `Annotated[int, Gt(0)]`.""" |
| 2197 | FieldInfo = import_cached_field_info() |
| 2198 | source_type, *annotations = self._get_args_resolving_forward_refs( |
| 2199 | annotated_type, |
| 2200 | required=True, |
| 2201 | ) |
| 2202 | schema = self._apply_annotations(source_type, annotations) |
| 2203 | # put the default validator last so that TypeAdapter.get_default_value() works |
| 2204 | # even if there are function validators involved |
| 2205 | for annotation in annotations: |
| 2206 | if isinstance(annotation, FieldInfo): |
| 2207 | schema = wrap_default(annotation, schema) |
| 2208 | return schema |
| 2209 | |
| 2210 | def _apply_annotations( |
| 2211 | self, |
no test coverage detected