| 714 | |
| 715 | |
| 716 | class DiscriminatorDetails: |
| 717 | field_name: str |
| 718 | """The name of the discriminator field in the variant class, e.g. |
| 719 | |
| 720 | ```py |
| 721 | class Foo(BaseModel): |
| 722 | type: Literal['foo'] |
| 723 | ``` |
| 724 | |
| 725 | Will result in field_name='type' |
| 726 | """ |
| 727 | |
| 728 | field_alias_from: str | None |
| 729 | """The name of the discriminator field in the API response, e.g. |
| 730 | |
| 731 | ```py |
| 732 | class Foo(BaseModel): |
| 733 | type: Literal['foo'] = Field(alias='type_from_api') |
| 734 | ``` |
| 735 | |
| 736 | Will result in field_alias_from='type_from_api' |
| 737 | """ |
| 738 | |
| 739 | mapping: dict[str, type] |
| 740 | """Mapping of discriminator value to variant type, e.g. |
| 741 | |
| 742 | {'foo': FooVariant, 'bar': BarVariant} |
| 743 | """ |
| 744 | |
| 745 | def __init__( |
| 746 | self, |
| 747 | *, |
| 748 | mapping: dict[str, type], |
| 749 | discriminator_field: str, |
| 750 | discriminator_alias: str | None, |
| 751 | ) -> None: |
| 752 | self.mapping = mapping |
| 753 | self.field_name = discriminator_field |
| 754 | self.field_alias_from = discriminator_alias |
| 755 | |
| 756 | |
| 757 | def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any, ...]) -> DiscriminatorDetails | None: |
no outgoing calls
no test coverage detected