Migration Guide
There is no YAML importer. Migration is a modeling exercise: describe the same channels, operations, messages, and servers in TypeSpec, then diff the emitted document against the one you have today. The diff is the review artifact.
From hand-written YAML
Section titled “From hand-written YAML”- Inventory the document. List every
channels,operations,components.messages, andcomponents.schemasentry. Most real documents have far fewer distinct parts than they appear to. - Model payloads first. Each message payload becomes a TypeSpec
model; shared schemas become named models so they land incomponents.schemasas reusable entries. - Add channels and operations.
@channel("address")on an operation creates the channel. Use@publishor@subscribeto state the action explicitly; the emitter can otherwise infer it from the operation name. - Move servers to the namespace.
@server("production", #{ url: "...", protocol: "kafka" })targets a namespace, not an operation. - Port bindings. Replace hand-written binding YAML with
@protocol(...)or@bindings(...). Versions are injected automatically, and fields are placed where the protocol expects them. - Port security. Declare schemes with
@security(...)and attach requirements with@operationSecurity(...). AsyncAPI 3.1 usesavailableScopes, which the emitter normalizes for you. - Compile and diff. Compare channel addresses, operation actions,
$refchains, and binding objects — not YAML formatting. Run the result through AsyncAPI Studio or the parser before deleting the old file.
From another TypeSpec emitter
Section titled “From another TypeSpec emitter”- Swap the package and the
emitentry intspconfig.yaml. - Replace its import with
import "@lars-artmann/typespec-asyncapi";and addusing TypeSpec.AsyncAPI;. - Recompile. Expect diagnostics for anything the previous emitter accepted silently: unknown protocols, misplaced bindings, malformed server URLs, invalid security scheme types.
- Reconcile decorator differences against Decorators. This emitter’s surface is documented there; do not assume another emitter’s decorator names or targets carry over.
- Update consumers for AsyncAPI 3.1 differences. If the previous output was 3.0, check
availableScopes, security requirement shapes, and component references.
Checklist
Section titled “Checklist”| Step | Done when |
|---|---|
| Payloads modeled | Every message payload is a named model or an explicit inline schema |
| Channels mapped | Every channel address appears exactly once in the output |
| Actions explicit | Every operation has @publish or @subscribe |
| Servers on namespace | @server decorates the namespace, and protocol is supported |
| Bindings placed | No misplaced-binding warning; bindingVersion is present |
| Security declared | Schemes exist in components.securitySchemes and requirements resolve |
| Validation clean | tsp compile emits no errors and no unexpected warnings |
| Consumer verified | AsyncAPI Studio or the parser accepts the document |
Common pitfalls
Section titled “Common pitfalls”@servercannot decorate an operation. Put it above the namespace declaration.#{}value literals are comma-separated. Model properties are not.- A blockless
namespace Foo;must be the first declaration in its file. - Reserved words (
model,enum,default, …) cannot be keys inside#{}. @deprecateddoes not exist in the standard library. Use the#deprecated "reason"compiler directive.@visibilityis lossy: read-only maps toreadOnly, create/update-only maps towriteOnly, and delete/query are ignored.
Where to go next
Section titled “Where to go next”- Examples — working specs for Kafka, MQTT, WebSocket, and reusable components
- Decorators — targets and configuration for all 30 decorators
- Diagnostics — every code and how to resolve it