Skip to content

Shape

🛈 DocStrings

An object shape of the upstream schema: a named definition or a union variant.

Source code in src/aclientp/schema_reference.py
@dataclass(frozen=True)
class Shape:
    """An object shape of the upstream schema: a named definition or a union variant."""

    key: str
    """``Name`` for a definition, ``Union[prop=value]`` for a tagged union variant."""

    properties: frozenset[str]
    """Wire names of all properties, including inherited (``allOf``) ones."""

    required: frozenset[str]
    """Wire names of required properties."""

    union: str | None = None
    """Name of the union a variant belongs to."""

    discriminator: tuple[str, str] | None = None
    """``(property, value)`` that selects a variant."""

    bases: frozenset[str] = frozenset()
    """Definitions this shape inherits via ``allOf``."""

    nullable: frozenset[str] = frozenset()
    """Wire names of properties that accept ``null``."""

    constraints: Mapping[str, Mapping[str, float]] = field(default_factory=dict)
    """Numeric and length constraints per property, as pydantic names (``ge``, ...)."""

    branch_of: str | None = None
    """For a variant made from a tagged branch inside an object definition: that
    definition. Our side models such an object either as one model of the same name,
    or as a union of the same name whose members are the branches."""

bases class-attribute instance-attribute

bases: frozenset[str] = frozenset()

Definitions this shape inherits via allOf.

branch_of class-attribute instance-attribute

branch_of: str | None = None

For a variant made from a tagged branch inside an object definition: that definition. Our side models such an object either as one model of the same name, or as a union of the same name whose members are the branches.

constraints class-attribute instance-attribute

constraints: Mapping[str, Mapping[str, float]] = field(default_factory=dict)

Numeric and length constraints per property, as pydantic names (ge, ...).

discriminator class-attribute instance-attribute

discriminator: tuple[str, str] | None = None

(property, value) that selects a variant.

key instance-attribute

key: str

Name for a definition, Union[prop=value] for a tagged union variant.

nullable class-attribute instance-attribute

nullable: frozenset[str] = frozenset()

Wire names of properties that accept null.

properties instance-attribute

properties: frozenset[str]

Wire names of all properties, including inherited (allOf) ones.

required instance-attribute

required: frozenset[str]

Wire names of required properties.

union class-attribute instance-attribute

union: str | None = None

Name of the union a variant belongs to.

:fa-brands-github: Show source on GitHub