litestar-asyncapi
Generate AsyncAPI 3.1 documents from Litestar WebSocket routes and serve packaged documentation. Requires Python 3.10–3.14 and Litestar >=2.24,<3. AsyncAPI 3.0 remains available with spec_version="3.0.0".
from dataclasses import dataclass
from litestar import Litestar, websocket_listener
from litestar.dto import DataclassDTO
from litestar_asyncapi import AsyncAPIConfig, AsyncAPIPlugin, DocsConfig
from litestar_asyncapi.spec import Server
@dataclass
class Message:
text: str
@websocket_listener("/chat", dto=DataclassDTO[Message])
async def chat(data: Message) -> Message:
return data
app = Litestar(
[chat],
plugins=[AsyncAPIPlugin(AsyncAPIConfig(
title="Chat", version="1.0.0",
docs=DocsConfig(interactive=True),
servers={"local": Server(host="localhost:8000", protocol="ws")},
))],
)
Save as app.py and run uv run litestar --app app:app run. Open /asyncapi/ for React documentation and /asyncapi/asyncapi.json for JSON. YAML is opt-in with DocsConfig(yaml=True). Python consumers need no Node installation.
Operations describe the application: incoming messages are receive, outgoing messages are send. Native Litestar schema generation supplies model schemas; fixed tuples export Draft07 positional items with exact length bounds.
Interaction defaults to off. The example enables the upstream WebSocket console: validation is advisory; Send transmits entered text even when invalid. Supported JSON text object/array contracts can connect to explicit servers. Binary, plain-text, JSON-string and ambiguous contracts remain documentation-only. The application must enforce its own validation and authorization.
AsyncAPI React component 3.2.1 (React 18.3.1) is the default renderer. DocsConfig(renderer="scalar") selects Scalar 1.69.2, which omits tuple positions, zero-length bounds and boolean schemas. With interactive=True, Scalar links to the shared React console at /asyncapi/playground.
Export without starting a server:
uv run litestar --app app:app asyncapi export
uv run litestar --app app:app asyncapi export --format yaml --output asyncapi.yaml
Existing files require --overwrite. Export also works with DocsConfig(enabled=False).
See the migration guide, runnable examples, and usage guides. Build documentation with make docs.
Development uses make lint, make test, make validate-asyncapi, and the locked Node 22 frontend toolchain. CI tests installed wheels across supported Python versions. Release workflows publish the tested wheel and its accompanying source distribution.
Release files for litestar-asyncapi 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| litestar_asyncapi-0.2.0.tar.gz | 2.2 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| litestar_asyncapi-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.2 MB
Release files / litestar_asyncapi-0.2.0.tar.gz
| Download URL | litestar_asyncapi-0.2.0.tar.gz |
|---|---|
| Size | 2.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2caaa849e35edb0774e7f18cc91b4a7c38634b3506ef2979c237da4a5868520
|
|
BLAKE2b-256 checksum How to use checksums |
614a97891de7827234cb3ac9a85644d7d9bf668c81989fb0cc56f06012870215
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency logRelease files / litestar_asyncapi-0.2.0-py3-none-any.whl
| Download URL | litestar_asyncapi-0.2.0-py3-none-any.whl |
|---|---|
| Size | 1.9 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d66a84acad8f92f439f0e42539c110deb09eda132b6d709afb8a9770e3b88d96
|
|
BLAKE2b-256 checksum How to use checksums |
5030e4b1e703799e64d66b647d6d89ee5d0c226656217d51b313176729c7b27c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency log