def get_app_schema(
broker: "BrokerUsecase[Any, Any]",
/,
title: str,
app_version: str,
schema_version: str,
description: str | None,
terms_of_service: Optional["AnyHttpUrl"],
contact: Union["SpecContact", "ContactDict", dict[str, Any]] | None,
license: Union["SpecLicense", "LicenseDict", dict[str, Any]] | None,
identifier: str | None,
tags: Sequence[Union["SpecTag", "TagDict", dict[str, Any]]],
external_docs: Union["SpecDocs", "ExternalDocsDict", dict[str, Any]] | None,
http_handlers: list[tuple[str, "HttpHandler"]],
) -> ApplicationSchema:
"""Get the application schema."""
servers = get_broker_server(broker)
channels = get_broker_channels(broker)
messages: dict[str, Message] = {}
payloads: dict[str, dict[str, Any]] = {}
for channel in channels.values():
channel.servers = list(servers.keys())
channels.update(get_asgi_routes(http_handlers))
for channel_name, ch in channels.items():
resolve_channel_messages(ch, channel_name, payloads, messages)
return ApplicationSchema(
info=ApplicationInfo(
title=title,
version=app_version,
description=description,
termsOfService=terms_of_service,
contact=Contact.from_spec(contact),
license=License.from_spec(license),
),
tags=[Tag.from_spec(tag) for tag in tags] or None,
externalDocs=ExternalDocs.from_spec(external_docs),
asyncapi=schema_version,
defaultContentType=ContentTypes.JSON.value,
id=identifier,
servers=servers,
channels=channels,
components=Components(
messages=messages,
schemas=payloads,
securitySchemes=None
if broker.specification.security is None
else broker.specification.security.get_schema(),
),
)