Convert Figma logo to code with AI

asyncapi logogenerator

Use your AsyncAPI definition to generate literally anything. Markdown documentation, Node.js code, HTML documentation, anything!

1,022
380
1,022
78

Top Related Projects

5,129

The AsyncAPI specification allows you to create machine-readable definitions of your asynchronous APIs.

5,129

The AsyncAPI specification allows you to create machine-readable definitions of your asynchronous APIs.

GUI / visual editor for creating and editing OpenAPI / Swagger definitions

4,855

Turn any OpenAPI2/3 and Postman Collection file into an API server with mocking, transformations and validations.

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)

Quick Overview

AsyncAPI Generator is a powerful tool designed to generate documentation, code, and other assets from AsyncAPI documents. It supports multiple templates and can be used as a CLI tool or integrated into other projects as a library. The generator is highly extensible, allowing users to create custom templates for various programming languages and frameworks.

Pros

  • Supports multiple programming languages and frameworks through templates
  • Highly customizable and extensible
  • Can be used as both a CLI tool and a library
  • Active community and regular updates

Cons

  • Learning curve for creating custom templates
  • Limited built-in templates compared to some other API documentation tools
  • May require additional setup for complex use cases
  • Performance can be slower for large AsyncAPI documents

Code Examples

  1. Generate documentation using the CLI:
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template -o ./output

This command generates HTML documentation from an AsyncAPI document using the official HTML template.

  1. Using the generator as a library in Node.js:
const generator = require('@asyncapi/generator');

const options = {
  templateName: '@asyncapi/html-template',
  output: './output',
  forceWrite: true,
};

generator.generate('asyncapi.yaml', options)
  .then(() => console.log('Done!'))
  .catch(console.error);

This example demonstrates how to use the generator as a library to generate documentation programmatically.

  1. Creating a custom template:
module.exports = {
  generate: async ({ asyncapi, templateParams, templateConfig }) => {
    // Custom generation logic here
    return {
      'output.txt': `Generated content for ${asyncapi.info.title}`
    };
  },
  templateConfig: {
    supportedProtocols: ['mqtt', 'kafka'],
    parameters: {
      // Template-specific parameters
    }
  }
};

This code snippet shows the basic structure of a custom template for the AsyncAPI Generator.

Getting Started

To get started with AsyncAPI Generator:

  1. Install the generator globally:

    npm install -g @asyncapi/generator
    
  2. Create an AsyncAPI document (e.g., asyncapi.yaml)

  3. Generate documentation using a template:

    asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template -o ./output
    
  4. View the generated output in the ./output directory

For more advanced usage, refer to the official documentation on the AsyncAPI Generator GitHub repository.

Competitor Comparisons

5,129

The AsyncAPI specification allows you to create machine-readable definitions of your asynchronous APIs.

Pros of spec

  • Focuses on defining the AsyncAPI specification, providing a standardized format for describing asynchronous APIs
  • Serves as the authoritative source for the AsyncAPI specification, ensuring consistency across implementations
  • Lighter weight and more focused in scope compared to generator

Cons of spec

  • Lacks code generation capabilities, which generator provides
  • Does not include tooling for working with AsyncAPI documents, unlike generator which offers various utilities

Code Comparison

spec:

asyncapi: 2.5.0
info:
  title: Example API
  version: 1.0.0
channels:
  user/signedup:
    publish:
      message:
        $ref: '#/components/messages/UserSignedUp'

generator:

const generator = new Generator('@asyncapi/html-template', {
  output: './output',
  templateParams: {
    singleFile: true
  }
});

await generator.generateFromFile('./asyncapi.yaml');

The spec repository focuses on defining the AsyncAPI specification structure, while generator provides tools for working with and generating code from AsyncAPI documents. spec is essential for standardization, while generator offers practical implementation and documentation generation capabilities.

5,129

The AsyncAPI specification allows you to create machine-readable definitions of your asynchronous APIs.

Pros of spec

  • Focuses on defining the AsyncAPI specification, providing a standardized format for describing asynchronous APIs
  • Serves as the authoritative source for the AsyncAPI specification, ensuring consistency across implementations
  • Lighter weight and more focused in scope compared to generator

Cons of spec

  • Lacks code generation capabilities, which generator provides
  • Does not include tooling for working with AsyncAPI documents, unlike generator which offers various utilities

Code Comparison

spec:

asyncapi: 2.5.0
info:
  title: Example API
  version: 1.0.0
channels:
  user/signedup:
    publish:
      message:
        $ref: '#/components/messages/UserSignedUp'

generator:

const generator = new Generator('@asyncapi/html-template', {
  output: './output',
  templateParams: {
    singleFile: true
  }
});

await generator.generateFromFile('./asyncapi.yaml');

The spec repository focuses on defining the AsyncAPI specification structure, while generator provides tools for working with and generating code from AsyncAPI documents. spec is essential for standardization, while generator offers practical implementation and documentation generation capabilities.

GUI / visual editor for creating and editing OpenAPI / Swagger definitions

Pros of openapi-gui

  • User-friendly graphical interface for creating and editing OpenAPI specifications
  • Real-time preview of the generated OpenAPI document
  • Supports importing existing OpenAPI specifications for editing

Cons of openapi-gui

  • Limited to OpenAPI specifications, while generator supports AsyncAPI
  • Less extensive code generation capabilities compared to generator
  • May require more manual input for complex API structures

Code Comparison

openapi-gui (HTML/JavaScript):

<div id="swagger-editor"></div>
<script src="https://unpkg.com/swagger-editor-dist/swagger-editor-bundle.js"></script>
<script>
  SwaggerEditorBundle.SwaggerEditor({ dom_id: '#swagger-editor' });
</script>

generator (JavaScript):

const generator = require('@asyncapi/generator');
const template = require('@asyncapi/html-template');

generator.generate(asyncapiDocument, template, {
  outputDir: './output'
}).then(() => console.log('Done!'));

While openapi-gui focuses on providing a visual interface for creating OpenAPI specifications, generator is more versatile, supporting AsyncAPI and offering extensive code generation capabilities. openapi-gui is better suited for users who prefer a graphical approach to API design, while generator caters to developers who need powerful code generation tools and support for AsyncAPI specifications.

4,855

Turn any OpenAPI2/3 and Postman Collection file into an API server with mocking, transformations and validations.

Pros of Prism

  • Supports multiple API specification formats (OpenAPI, Postman Collections)
  • Offers mock server functionality for API testing
  • Provides a CLI tool for easy integration into workflows

Cons of Prism

  • Focused primarily on HTTP APIs, less suitable for event-driven architectures
  • Limited template customization options compared to Generator
  • Lacks extensive code generation capabilities

Code Comparison

Generator:

const generator = new AsyncAPIGenerator();
await generator.generateFromFile('asyncapi.yaml', './output');

Prism:

const { Prism } = require('@stoplight/prism-core');
const { createServer } = require('@stoplight/prism-http-server');

const prism = new Prism({ specification: './openapi.yaml' });
createServer(prism, { port: 4010 });

Generator focuses on generating code and documentation from AsyncAPI specifications, while Prism primarily serves as a mock server and validator for OpenAPI specifications. Generator offers more flexibility in terms of output customization and supports a wider range of use cases for event-driven architectures. Prism, on the other hand, excels in API mocking and testing scenarios, making it a valuable tool for API development and integration testing.

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.

Pros of Swagger Codegen

  • Mature project with extensive language support
  • Large community and ecosystem
  • Supports both client and server code generation

Cons of Swagger Codegen

  • Primarily focused on REST APIs, limited support for other protocols
  • Can be complex to customize and extend
  • Slower development cycle and release process

Code Comparison

Swagger Codegen (Java):

public class PetApi {
    private final ApiClient apiClient;

    public PetApi() {
        this(Configuration.getDefaultApiClient());
    }
}

AsyncAPI Generator (JavaScript):

const generator = new Generator('@asyncapi/html-template', {
  output: './output',
  params: {
    singleFile: true
  }
});

Key Differences

  • AsyncAPI Generator focuses on event-driven architectures and async APIs
  • Swagger Codegen primarily targets REST APIs
  • AsyncAPI Generator offers a more modern, modular approach
  • Swagger Codegen provides broader language support
  • AsyncAPI Generator has a faster development cycle and more frequent releases

Both tools serve different purposes and can be complementary in API development workflows. AsyncAPI Generator is better suited for modern, event-driven architectures, while Swagger Codegen excels in traditional REST API scenarios with its extensive language support and mature ecosystem.

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)

Pros of openapi-generator

  • Supports a wider range of programming languages and frameworks
  • More extensive documentation and community support
  • Offers more customization options for generated code

Cons of openapi-generator

  • Steeper learning curve due to its complexity
  • Can be slower to generate code for large specifications
  • May produce more verbose output compared to asyncapi-generator

Code Comparison

generator (AsyncAPI):

const generator = new Generator('@asyncapi/html-template', '/path/to/asyncapi.yaml');
await generator.generate('/output/directory');

openapi-generator:

openapi-generator generate -i /path/to/openapi.yaml -g javascript -o /output/directory

Key Differences

  • generator focuses on AsyncAPI specifications, while openapi-generator is designed for OpenAPI (formerly Swagger) specifications
  • generator is primarily JavaScript-based, whereas openapi-generator is implemented in Java
  • openapi-generator offers a wider range of output formats and languages, but generator provides more specialized support for event-driven architectures

Both tools serve different purposes within the API ecosystem, with generator being more focused on asynchronous APIs and openapi-generator offering broader support for RESTful APIs across multiple languages and frameworks.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

AsyncAPI Generator

This is a Monorepo managed using Turborepo and contains the following package:

  1. Generator: This is a tool that you can use to generate whatever you want basing on the AsyncAPI specification file as an input.

  2. Nunjucks-filters: This library contains generator filters that can be reused across multiple templates, helping to avoid redundant work. These filters are designed specifically for Nunjucks templates and are included by default with the generator, so there's no need to add them to dependencies seprately.

npm npm

warning: This package doesn't support AsyncAPI 1.x anymore. We recommend to upgrade to the latest AsyncAPI version using the AsyncAPI converter (You can refer to installation guide). If you need to convert documents on the fly, you may use the Node.js or Go converters.

Overview

Generator is a tool that you can use to generate whatever you want basing on the AsyncAPI specification file as an input. For more information read the docs.

There is a large number of templates that are ready to use and are officially supported by the AsyncAPI Initiative.

List of official generator templates

Template NameDescriptionSource code
@asyncapi/nodejs-templateGenerates Nodejs service that uses Hermes packageclick here
@asyncapi/nodejs-ws-templateGenerates Nodejs service that supports WebSockets protocol onlyclick here
@asyncapi/java-templateGenerates Java JMS applicationclick here
@asyncapi/java-spring-templateGenerates Java Spring serviceclick here
@asyncapi/java-spring-cloud-stream-templateGenerates Java Spring Cloud Stream serviceclick here
@asyncapi/python-paho-templateGenerates Python service that uses Paho libraryclick here
@asyncapi/html-templateGenerates HTML documentation siteclick here
@asyncapi/markdown-templateGenerates documentation in Markdown fileclick here
@asyncapi/ts-nats-templateGenerates TypeScript NATS clientclick here
@asyncapi/go-watermill-templateGenerates Go client using Watermillclick here
@asyncapi/dotnet-nats-templateGenerates .NET C# client using NATSclick here
@asyncapi/php-templateGenerates PHP client using RabbitMQclick here
@asyncapi/dotnet-rabbitmq-templateGenerates .NET C# client using RabbitMQclick here

You can find above templates and the ones provided by the community in this list

Generator Filters

This library contains generator filters that can be reused across multiple templates, helping to avoid redundant work. These filters are designed specifically for Nunjucks templates and are included by default with the generator, so there's no need to add them to dependencies seprately.

This library consists of:

  • Custom filters. Check out API docs for complete list
  • Lodash-powered filters. For the list of all available filters check official docs

Release Process

To release a major/minor/patch:

Conventional Commits:

To maintain a clear git history of commits and easily identify what each commit changed and whether it triggered a release, we use conventional commits. The feat and fix prefixes are particularly important as they are needed to trigger changesets. Using these prefixes ensures that the changes are correctly categorized and the versioning system functions as expected.

For Example:

feat: add new feature

Manual

  1. Create a new release markdown file in the .changeset directory. The filename should indicate what the change is about.

  2. Add the following content to the file in this particular format:

    ---
    "@package-name-1": [type] (major/minor/patch)
    "@package-name-2": [type]
    ---
    
    [Provide a brief description of the changes. For example: Added a new Release GitHub Flow to the Turborepo. No new features or bugfixes were introduced.]
    

    For Example:

    ---
    "@asyncapi/generator": minor
    ---
    
    Adding new Release Github Flow to the Turborepo. No new features or bugfixes were introduced.
    
    
  3. Include the file in your pull request.

Using CLI

  1. Create a new release markdown file using changeset CLI. Below command will trigger an interactive prompt that you can use to specify release type and affected packages.

    npx -p @changesets/cli@2.27.7 changeset
    
  2. Include the file in your pull request.

[!TIP] For more detailed instructions, you can refer to the official documentation for creating a changeset: Adding a changeset

Release Flow:

  1. Add a Changeset:

    • When you make changes that need to be released, create a markdown file in the .changeset directory stating the package name and level of change (major/minor/patch).
  2. Open a Pull Request:

    • Push your changes and open a Pull Request (PR). After the PR is merged the changeset file helps communicate the type of changes (major, minor, patch).
  3. CI Processes Changeset:

    • After PR is merged, a dedicated GitHub Actions release workflow runs using changeset action,

    • This action reads the markdown files in the .changeset folder and creates a PR with the updated version of the package and removes the markdown file. For example:

      Before:

      "name": "@asyncapi/generator",
      "version": "2.0.1",
      

      After:

      "name": "@asyncapi/generator",
      "version": "3.0.1",
      
    • The new PR will also contain the description from the markdown files,

    • AsyncAPI bot automatically merge such release PR.

  4. Release the Package:

    • After the PR is merged, the CI/CD pipeline triggers again. The changesets/action step identifies that the PR was created by itself. It then verifies if the current version of the package is greater than the previously released version. If a difference is detected, it executes the publish command to release the updated package.

Contributing

Read CONTRIBUTING guide.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Fran Méndez
Fran Méndez

💬 🐛 💻 📖 🤔 🚧 🔌 👀 ⚠️ ✅
Jonas Lagoni
Jonas Lagoni

💬 🐛 💻 📖 🤔 🔌 👀 ⚠️
Lukasz Gornicki
Lukasz Gornicki

💬 🐛 📝 💻 📖 🤔 🚧 🔌 👀 ⚠️ ✅ 🚇
Travis Reeder
Travis Reeder

🚇 📖
Semen
Semen

🐛 💻 📖 🤔 🔌 👀 ⚠️
Waleed Ashraf
Waleed Ashraf

💻 🐛
Sebastián
Sebastián

💻
Derk Muenchhausen
Derk Muenchhausen

💻
Ben Timby
Ben Timby

💻
Amanda  Shafack
Amanda Shafack

📖
Florence Njeri
Florence Njeri

📖 👀 🚇 🚧
Pratik Haldankar
Pratik Haldankar

📖 👀 🚧 📢
swastik suvam singh
swastik suvam singh

💻
GavinZhengOI
GavinZhengOI

📖
lmgyuan
lmgyuan

📖
pierrick-boule
pierrick-boule

💻 ⚠️ 📖

This project follows the all-contributors specification. Contributions of any kind welcome!

NPM DownloadsLast 30 Days