Skip to content

Examples

Every example is a self-contained TypeSpec project. CI compiles all of them with zero diagnostics and validates each emitted document against the official AsyncAPI 3.1.0 JSON Schema.

Example What it shows
streetlights-mqtt The canonical AsyncAPI Streetlights example: MQTT server with variables, channel address templating via @parameter, constraints, and enum payloads.
kafka-orders Kafka bindings at spec-correct placements (topic/partitions/replicas on the channel, groupId on the operation), scramSha512 security, and @discriminator polymorphism.
websocket-chat WebSocket bindings (method/query), @header, @correlationId, @reply with a runtime-expression address, and generic Page<T> schema naming.
reusable-components The components.* showcase: @operationTrait, @messageTrait, @parameter, @reusableCorrelationId, @reusableBinding, and @useChannelServer.
split-schemas Multi-file output: one file per schema, with every $ref rewritten to an external path.
Example What it shows
simple / smoke / basic-events Minimal getting-started specs, including a custom output-file.
kafka Kafka bindings with a schema-keyed payload.
multi-channel Multiple channels sharing models.
comprehensive-protocols Many protocols in one document.
advanced Advanced decorator combinations.
real-world Four realistic multi-file event systems (HTTP, Kafka, WebSocket, multi-protocol).
mixed-rest-events A REST namespace and an event namespace in one program, without phantom OpenAPI routes.
schema-extensions @jsonSchemaExtension and @extension vendor keywords.
Terminal window
git clone https://github.com/LarsArtmann/typespec-asyncapi
cd typespec-asyncapi
pnpm install
pnpm run build
pnpm run check-examples

Or compile one example by hand:

Terminal window
cd examples/streetlights-mqtt
pnpm exec tsp compile main.tsp
cat tsp-output/@lars-artmann/typespec-asyncapi/asyncapi.yaml