Skip to content

License

faststream.specification.asyncapi.v2_6_0.schema.license.License #

Bases: BaseModel

A class to represent a license.

ATTRIBUTE DESCRIPTION
name

name of the license

url

URL of the license (optional)

Config

extra : allow additional attributes in the model (PYDANTIC_V2)

name instance-attribute #

name

url class-attribute instance-attribute #

url = None

model_config class-attribute instance-attribute #

model_config = {'extra': 'allow'}

Config #

extra class-attribute instance-attribute #

extra = 'allow'

from_spec classmethod #

from_spec(license: None) -> None
from_spec(license: License) -> Self
from_spec(license: LicenseDict) -> Self
from_spec(license: dict[str, Any]) -> dict[str, Any]
from_spec(license)
Source code in faststream/specification/asyncapi/v2_6_0/schema/license.py
@classmethod
def from_spec(
    cls,
    license: SpecLicense | LicenseDict | dict[str, Any] | None,
) -> Self | dict[str, Any] | None:
    if license is None:
        return None

    if isinstance(license, SpecLicense):
        return cls(
            name=license.name,
            url=license.url,
        )

    license = cast("dict[str, Any]", license)
    license_data, custom_data = filter_by_dict(LicenseDict, license)

    if custom_data:
        return license

    return cls(**license_data)