Clean-break migration¶
This redesign makes intentional API breaks without a deprecation layer. Upgrade
Litestar to >=2.24,<3 and test the generated document and your actual wire
messages. Python 3.11–3.15 is supported.
Configuration and imports¶
- Import
AsyncAPIPluginfromlitestar_asyncapiorlitestar_asyncapi.plugins. The singularlitestar_asyncapi.pluginmodule is removed; the consolidatedpluginspackage exports application and render plugins. - Move flat documentation settings
into
AsyncAPIConfig(docs=DocsConfig(...)). Selectrenderer="asyncapi"(default) or"scalar"insideDocsConfig. - YAML routes now require
DocsConfig(yaml=True). There is no separate YAML extra: current Litestar requires PyYAML even when the route is disabled. JsonRenderPluginandYamlRenderPluginare native Litestar classes.JSONRenderPlugin,YAMLRenderPluginandPlaygroundRenderPluginwere incorrect documentation names; use the actual mixed-case native names. Native defaults are OpenAPI paths/media types. UseDocsConfigdefaults or configure AsyncAPI paths and vendor MIME types explicitly.AsyncAPIPlaygroundRenderPluginand its bespoke JavaScript are removed. EnableDocsConfig(interactive=True)for the shared upstream React console. The redundantconsoleflag is removed. Validation is advisory and invalid input may be deliberately sent; runtime validation belongs in your application.- Old CDN script/style renderer options are removed. Browser assets are packaged and versioned with the wheel. Scalar is opt-in because of its documented tuple, zero-length and boolean-schema display gaps.
- Remove
random_seedand customcreate_examplesfactory objects/mappings.create_examplesis a boolean; explicit examples provide reproducibility. - Remove imports from
litestar_asyncapi.typingand._typing. Deleted exports areATTRS_INSTALLED,MSGSPEC_INSTALLED,PYDANTIC_INSTALLED,BaseModel,Struct,attrs_fields,attrs_hasandattrs_nothing. Import real model types from their libraries and use native Litestar plugins. - The empty
litestar_asyncapi.extensionsnamespace andspec.base.UnsetTypeare removed.spec.base.UNSETremains and is now nativelitestar.types.Empty. Explicit null and omitted fields remain distinct. - Custom AsyncAPI schema plugins, the duplicate registry and helper modules are
removed. Register a native Litestar
OpenAPISchemaPluginon the application; see Schema generation. No fallback duplicate type engine remains.
The direct configuration moves are:
| Previous configuration | New configuration |
|---|---|
AsyncAPIConfig(path="/events") |
AsyncAPIConfig(docs=DocsConfig(path="/events")) |
AsyncAPIConfig(enable_routes=False) |
AsyncAPIConfig(docs=DocsConfig(enabled=False)) |
AsyncAPIConfig(render_plugins=[...]) |
AsyncAPIConfig(docs=DocsConfig(render_plugins=[...])) |
Documentation guards and dependencies are configured on DocsConfig. The old
column describes removed APIs and is not executable with the new release.
Top-level message_traits and operation_traits mappings remain supported
on AsyncAPIConfig. Components is an optional unified declaration for
traits and other reusable components.
Document and discovery changes¶
- The document title, version and description now come from the application's
OpenAPIConfigwhenAsyncAPIConfigleaves them unset, so an application without its own title showsLitestar APIinstead ofAsyncAPI. Set the fields explicitly, or passinherit_openapi=False, to keep the old values. - AsyncAPI 3.1.0 is the default; select
spec_version="3.0.0"explicitly when needed. The root no longer assumesdefaultContentType: application/jsonfor uncertain wire formats. Known inferred messages carry their own content type. - Operation direction is application-relative: input is
receive, output issend. Earlier client-relative documentation was incorrect. Generated Channels sockets are send-only; their receive loop does not process incoming payloads. operation_idremains decorator/definition metadata but becomes anoperationsmap key. There is nooperationIdwire field or spec-model constructor argument. IDs remain case-insensitively unique.- Use
MessageDefinition,OperationDefinitionandChannelDefinitionfor explicit contracts. Multiple named messages per operation are supported. Channel key and destination address are separate; operations reference their selected channel's messages. Conflicts now fail with deterministic provenance diagnostics. - Fixed tuples export Draft07
items: [schema, ...]and length bounds, replacing the incorrectprefixItemswire representation. Variadic tuples remain unbounded. Unsupported modern semantics fail explicitly; explicitMultiFormatSchemaremains available. - Message examples are wire
MessageExampleobjects ({"payload": ...}), not arbitrary bare entries. Decorator example values are wrapped for you. An explicit empty list suppresses fallback generation, and explicit null is preserved. - Operation/server security entries are scheme names, schemes or references,
not OpenAPI requirement-name maps. Name a scheme from
Components.security_schemesor one inherited from the OpenAPI config, for examplesecurity=["BearerToken"]. Security requirements are not inherited. - Only finalized native routes are inferred. Internal Channels subscriptions no
longer create phantom endpoints. Declare external broker channels explicitly.
Raw sockets require explicit metadata, or opt into uncertain discovery with
include_raw_websocket_routes=True. HTTP routes that returnServerSentEventare documented as send-only channels; see Server-Sent Events. - A plugin instance belongs to one app, including with caching disabled. Public
mutable accessors return defensive copies.
clear_cache()preserves ownership.
Before deploying, inspect JSON output and test real application encoders, DTOs, security and message validation. Documentation guards and security declarations are separate from socket authorization. See Documentation and interaction for the precise interactive capability boundary and the runnable examples for executable examples.