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. Hooks: Hooks are designed to let template developers hook into the template generation process. For example, one can create a hook code that will be automatically invoked right after the template generation process has ended.

  3. React-sdk: AsyncAPI React SDK is a set of components/functions to use React as render engine for the generator. This is the library that undestand components from Generator's templates that are configured to use react render engine.

  4. Generator-helpers: A utility library that provides helper functions and utilities to simplify template development. It reduces boilerplate and speeds up template creation.

  5. Generator-components: A library of reusable components that can be shared across different templates, helping to avoid duplication and accelerate template development.

npm npm

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

[!IMPORTANT] Experimental Feature: AsyncAPI Generator also comes with baked-in templates - official templates shipped directly inside the Generator (@asyncapi/generator). They cover code, docs, configs, and SDKs, and are maintained under /packages/templates directory, following a strict, opinionated structure for consistency and ease of maintenance. This feature is not recommended for production use. For those who want to try them out or learn more, see the Baked-in templates documentation.

Hooks

Hooks are functions called by the generator at specific moments in the generation process. Hooks can be anonymous functions, but you can also assign them function names. These hooks can have arguments provided to them, or they may be expected to return a value.

These hooks are included in the generator without adding any specific dependency to the library. You still have to enable the given hook in the configuration explicitly because some hooks can execute automatically without passing a specific parameter. Learn more about configuration and what hooks are available out of the box.

Contributing

For the development setup, you can follow the detailed guide in Developement guide

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

💻 ⚠️ 📖
Dhairya Majmudar
Dhairya Majmudar

🐛
Mintu Gogoi
Mintu Gogoi

🐛 💻 🤔 📖 👀 ⚠️
AdityaPat_
AdityaPat_

🚇
Achal Jhawar
Achal Jhawar

⚠️
Shuaib S.
Shuaib S.

⚠️ 📖 🚇
Adi Boghawala
Adi Boghawala

🐛 💻 🤔 🚇 👀 ⚠️ 📖 🚧
Kunal Nasa
Kunal Nasa

💻 📖 🐛
V Thulisile Sibanda
V Thulisile Sibanda

⚠️
Ahmed Atwa
Ahmed Atwa

⚠️ 🚇
Sarvesh.Patil
Sarvesh.Patil

⚠️ 👀
Mohan Kumar
Mohan Kumar

👀 💻 🤔
Moderator
Moderator

💻 📖 ⚠️
ANIRUDH
ANIRUDH

⚠️
Julian Waller
Julian Waller

🐛 ⚠️ 💻

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

NPM DownloadsLast 30 Days