(self, field: CoreSchemaField, name: str)
| 1537 | return json_schema |
| 1538 | |
| 1539 | def _get_alias_name(self, field: CoreSchemaField, name: str) -> str: |
| 1540 | if field['type'] == 'computed-field': |
| 1541 | alias: Any = field.get('alias', name) |
| 1542 | elif self.mode == 'validation': |
| 1543 | alias = field.get('validation_alias', name) |
| 1544 | else: |
| 1545 | alias = field.get('serialization_alias', name) |
| 1546 | if isinstance(alias, str): |
| 1547 | name = alias |
| 1548 | elif isinstance(alias, list): |
| 1549 | alias = cast('list[str] | str', alias) |
| 1550 | for path in alias: |
| 1551 | if isinstance(path, list) and len(path) == 1 and isinstance(path[0], str): |
| 1552 | # Use the first valid single-item string path; the code that constructs the alias array |
| 1553 | # should ensure the first such item is what belongs in the JSON schema |
| 1554 | name = path[0] |
| 1555 | break |
| 1556 | else: |
| 1557 | assert_never(alias) |
| 1558 | return name |
| 1559 | |
| 1560 | def typed_dict_field_schema(self, schema: core_schema.TypedDictField) -> JsonSchemaValue: |
| 1561 | """Generates a JSON schema that matches a schema that defines a typed dict field. |
no test coverage detected