Template

Found an error? Have a suggestion?Edit this page on GitHub

Template

A template is a project that specifies the generation process output by using the AsyncAPI generator and an AsyncAPI document. These files describe the generation results depending on the AsyncAPI document's content.

Examples outputs:

  • Code
  • Documentation
  • Markdown diagrams
  • Python and Java applications

A template is an independent Node.js project unrelated to the generator repository. AsyncAPI templates are managed, released, and published separately. You can also create templates and manage templates on your own.

The generator uses the official Arborist NPM library. (This means templates do not have to be published to package managers to use them.) Arborist helps the generator fetch the template's source code and use it for the generation process. By default, this library pulls data from the default NPM registry, which is https://registry.npmjs.org. You can also configure the generator to fetch templates that are private or hosted in different NPM registry

You can store template projects on a local drive or as a git repository during the development process.

Template generation process

  1. Template is provided as input to the Generator.
  2. asyncapi is the original AsyncAPI document injected into your template file by default.
  3. params are the parameters you pass to the AsyncAPI CLI. Later, you can also pass these params further to other components.
  4. The generator passes both the original asyncapi, the original AsyncAPI document, and the params to the Template Context.
  5. Concurrently, the generator passes Template files to the Render engine as well. AsyncAPI uses two render engines — react and nunjucks.
  6. Once the Render Engine receives both the Template Files and the Template Context, it injects all the dynamic values into your react or nunjucks engine, based on the Template Files using the Template Context.
  7. The render engine generates whatever output you may have specified in your template. (i.e. code, documentation, diagrams, pdfs, applications, etc.)

Generator templates list

AsyncAPI has a list of available templates to enhance your generation process. Templates are stored as repositories on AsyncAPI's official GitHub profile.

Template NameDescriptionSource code
@asyncapi/nodejs-templateGenerates Node.js service that uses Hermes packageNode.js template
@asyncapi/nodejs-ws-templateGenerates Node.js service that supports WebSocket protocol onlyNode.js WebSocket template
@asyncapi/java-templateGenerates Java JMS applicationJava template
@asyncapi/java-spring-templateGenerates Java Spring serviceJava spring template
@asyncapi/java-spring-cloud-stream-templateGenerates Java Spring Cloud Stream serviceJava spring cloud stream template
@asyncapi/python-paho-templateGenerates Python service that uses Paho libraryPython paho template
@asyncapi/html-templateGenerates HTML documentation siteHTML template
@asyncapi/markdown-templateGenerates documentation in Markdown fileMarkdown template
@asyncapi/ts-nats-templateGenerates TypeScript NATS clientTypeScript/Node.js NATS template
@asyncapi/go-watermill-templateGenerates Go client using WatermillGO watermill template
@asyncapi/dotnet-nats-templateGenerates .NET C# client using NATS.NET C# NATS template

Some of these templates are maintained by various third-party organizations. The README file usually contains this information and more, such as configuration options the user can pass to the template, usage, technical requirements, etc.

Check out all our community generator templates

Was this helpful?
Help us improve the docs by adding your contribution.
OR
Github:AsyncAPICreate Issue on GitHub