singer_sdk.typing.DiscriminatedUnion¶
- class singer_sdk.typing.DiscriminatedUnion[source]¶
A discriminator property.
This is a special case of
singer_sdk.typing.OneOf
, where values are JSON objects, and the type of the object is determined by a property in the object.The property is a
singer_sdk.typing.Constant
called the discriminator property.- __init__(key, **options)[source]¶
Initialize a discriminated union type.
- Parameters:
key (str) – Name of the discriminator property.
options (ObjectType) – Mapping of discriminator values to object types.
- Return type:
None
Examples
>>> t = DiscriminatedUnion("species", cat=ObjectType(), dog=ObjectType()) >>> print(t.to_json(indent=2)) { "oneOf": [ { "type": "object", "properties": { "species": { "const": "cat", "description": "Discriminator for object of type 'cat'." } }, "required": [ "species" ] }, { "type": "object", "properties": { "species": { "const": "dog", "description": "Discriminator for object of type 'dog'." } }, "required": [ "species" ] } ] }