Bases: BaseModel
A class to represent a contact.
url: AnyHttpUrl | None = None
email: EmailStr | None = None
model_config = {'extra': 'allow'}
from_spec(contact: None) -> None
from_spec(contact: Contact) -> Self
from_spec(contact: dict[str, Any]) -> dict[str, Any]
from_spec(
contact: Contact | ContactDict | dict[str, Any] | None,
) -> Self | dict[str, Any] | None
Source code in faststream/specification/asyncapi/v2_6_0/schema/contact.py
| @classmethod
def from_spec(
cls,
contact: SpecContact | ContactDict | dict[str, Any] | None,
) -> Self | dict[str, Any] | None:
if contact is None:
return None
if isinstance(contact, SpecContact):
return cls(
name=contact.name,
url=contact.url,
email=contact.email,
)
contact = cast("dict[str, Any]", contact)
contact_data, custom_data = filter_by_dict(ContactDict, contact)
if custom_data:
return contact
return cls(**contact_data)
|