Installation
Who is this for? Event-driven API architects, platform engineers, and backend teams already using TypeSpec who want a typed, validated AsyncAPI 3.1 source of truth instead of hand-written YAML.
When not to use it: if your team does not use TypeSpec, or you only need a one-off AsyncAPI document, hand-written YAML plus the AsyncAPI Studio is simpler. This emitter pays off when the spec is generated repeatedly and must stay in lockstep with typed source.
Requirements
Section titled “Requirements”- Node.js 20.11 or newer
- The TypeSpec compiler (
tspCLI), 1.15 or newer - A package manager: pnpm, npm, yarn, or bun
Install the emitter
Section titled “Install the emitter”pnpm add @lars-artmann/typespec-asyncapi @typespec/compileror with npm:
npm install @lars-artmann/typespec-asyncapi @typespec/compilerWire it into tspconfig.yaml
Section titled “Wire it into tspconfig.yaml”The emitter is loaded by the tsp compiler via tspconfig.yaml:
emit: - "@lars-artmann/typespec-asyncapi"options: "@lars-artmann/typespec-asyncapi": file-type: yamlSee Emitter Options for the full option list (output file, format, pretty-printing, split-schemas, asyncapi-id, and more).
Verify the install
Section titled “Verify the install”Create a minimal spec and compile it:
npx tsp compile api.tspThe output lands in tsp-output/@lars-artmann/typespec-asyncapi/asyncapi.yaml.
Where to go next
Section titled “Where to go next”- Quick Start — your first channel, operation, and message in 5 minutes
- Decorators — all 30 decorators with targets and examples
- Protocol Bindings — Kafka, MQTT, WebSocket, and 16 more
- Related Tools — AsyncAPI Studio, Spectral, and sibling emitters