Bases: BaseModel
A class to represent a license.
Config
extra : allow additional attributes in the model (PYDANTIC_V2)
url class-attribute instance-attribute
url: AnyHttpUrl | None = None
model_config class-attribute instance-attribute
model_config = {'extra': 'allow'}
from_spec classmethod
from_spec(license: None) -> None
from_spec(license: License) -> Self
from_spec(license: dict[str, Any]) -> dict[str, Any]
from_spec(
license: License | LicenseDict | dict[str, Any] | None,
) -> Self | dict[str, Any] | None
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)
|