MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / DiscriminatorDetails

Class DiscriminatorDetails

src/opencode_ai/_models.py:570–608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

568
569
570class DiscriminatorDetails:
571 field_name: str
572 """The name of the discriminator field in the variant class, e.g.
573
574 ```py
575 class Foo(BaseModel):
576 type: Literal['foo']
577 ```
578
579 Will result in field_name='type'
580 """
581
582 field_alias_from: str | None
583 """The name of the discriminator field in the API response, e.g.
584
585 ```py
586 class Foo(BaseModel):
587 type: Literal['foo'] = Field(alias='type_from_api')
588 ```
589
590 Will result in field_alias_from='type_from_api'
591 """
592
593 mapping: dict[str, type]
594 """Mapping of discriminator value to variant type, e.g.
595
596 {'foo': FooVariant, 'bar': BarVariant}
597 """
598
599 def __init__(
600 self,
601 *,
602 mapping: dict[str, type],
603 discriminator_field: str,
604 discriminator_alias: str | None,
605 ) -> None:
606 self.mapping = mapping
607 self.field_name = discriminator_field
608 self.field_alias_from = discriminator_alias
609
610
611def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any, ...]) -> DiscriminatorDetails | None:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected