Skip to main content

Sample Catalog

Every sample is a runnable Nest application that generates an AsyncAPI 3.0 document and validates it with @asyncapi/parser. They use no external broker — transport is out of scope for this package — so they run anywhere.

npm run ci:sample
npm run sample:focused

Runnable Today

SampleFocusCommand
00-showcaseAll five decorators, class-validator and Zod payloads, Kafka and NATS bindings, and the docs route with viewernpm run showcase
01-validation-class-validator@AsyncApiMessage / @AsyncApiHeaders with class-validator DTOsnpm run test --workspace nest-native-asyncapi-sample-01-validation-class-validator
02-validation-zodA Zod payload via z.toJSONSchema()npm run test --workspace nest-native-asyncapi-sample-02-validation-zod
03-transport-bindings@AsyncApiServer plus Kafka, NATS, MQTT, and AMQP bindings across every scopenpm run test --workspace nest-native-asyncapi-sample-03-transport-bindings
04-docs-routeAsyncApiModule.setup serving the viewer and the JSON/YAML spec routesnpm run test --workspace nest-native-asyncapi-sample-04-docs-route
05-migration-nestjs-asyncapiThe nestjs-asyncapi 2.x felines sample ported to AsyncAPI 3.0npm run test --workspace nest-native-asyncapi-sample-05-migration-nestjs-asyncapi
06-forrootasync-configAsyncApiModule.forRootAsync resolving the document defaults from an injected ConfigServicenpm run test --workspace nest-native-asyncapi-sample-06-forrootasync-config

What The Showcase Proves

The showcase is intentionally rich — richness proves integration depth:

  • All five decorators end-to-end, plus the three binding decorators.
  • Both validation worlds: class-validator DTOs for orders, a Zod payload for shipments, in one document.
  • Multiple transport bindings (Kafka and NATS at minimum).
  • A live docs route served over HTTP with the AsyncAPI viewer.
  • The generated spec validated against @asyncapi/parser on every run.

Focused Samples

Each focused sample isolates one concept so you can copy the exact pattern you need:

  • Validation01 (class-validator) and 02 (Zod) show the two schema source styles described in Validation.
  • Bindings03 shows Kafka, NATS, MQTT, and AMQP bindings at the server, channel, operation, and message scopes described in Bindings.
  • Docs route04 boots over HTTP and validates the served JSON and YAML, matching Docs Route.
  • Migration05 is the validated port behind the Migration guide.
  • Async configuration06 registers the module with AsyncApiModule.forRootAsync, resolving the document defaults from an injected ConfigService before generating the document.