Generate Code from AsyncAPI Documents
This tutorial explains how to generate code from your AsyncAPI documents using the official AsyncAPI Generator.
Prerequisites
- Node.js v20.12.0 or later
- npm v10.5.0 or later
- An AsyncAPI document
Installing the Generator
Install the AsyncAPI Generator globally using npm:
npm install -g @asyncapi/generatorBasic Usage
The basic syntax for generating code is:
ag <asyncapi-file> <template> [options]For example, to generate HTML documentation:
ag asyncapi.yaml @asyncapi/html-templateAvailable Templates
The AsyncAPI Generator supports many official templates:
@asyncapi/html-template- Generate HTML documentation@asyncapi/nodejs-template- Generate Node.js applications@asyncapi/java-template- Generate Java applications@asyncapi/python-template- Generate Python applications@asyncapi/go-template- Generate Go applications
View all available templates in the template repository.
Template Options
Most templates support configuration options. To see available options:
ag help <template>For example:
ag help @asyncapi/nodejs-templateCustom Templates
You can create your own templates for specific use cases. See the Template Development Guide for details.
Next Steps
- Explore the AsyncAPI Generator documentation
- Learn about creating custom templates
- Join our community for help