@asyncapi/generator
The AsyncAPI generator. It can generate documentation, code, anything!
Last updated 12 hours ago by asyncapi-bot .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @asyncapi/generator -g
SYNC missed versions from official npm registry.

AsyncAPI Generator

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

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. If you need to convert documents on the fly, you may use the Node.js or Go converters.

Requirements

  • Node.js v12.16+
  • npm v6.13.7+

Install both packages using official installer. After installation make sure both packages have proper version by running node -v and npm -v. To upgrade invalid npm version run npm install npm@latest -g

Install

npm install -g @asyncapi/generator

Or just use Docker:

docker run --rm -it \
-v [ASYNCAPI FILE LOCATION]:/app/asyncapi.yml \
-v [GENERATED FILES LOCATION]:/app/output \
asyncapi/generator [COMMAND HERE]
# Example that you can run inside generator directory after cloning this repository. First you specify mount in location of your AsyncAPI file and then you mount in directory where generation result should be saved.
docker run --rm -it \
-v ${PWD}/test/docs/streetlights.yml:/app/asyncapi.yml \
-v ${PWD}/output:/app/output \
asyncapi/generator -o ./output asyncapi.yml @asyncapi/html-template --force-write

Usage

From the command-line interface (CLI)

Usage: cli [options] <asyncapi> <template>

Options:
  -V, --version                  output the version number
  -d, --disable-hook <hookType>  disable a specific hook type
  --debug                        enable more specific errors in the console. At the moment it only shows specific errors about filters. Keep in mind that as a result errors about template are less descriptive
  -i, --install                  installs the template and its dependencies (defaults to false)
  -n, --no-overwrite <glob>      glob or path of the file(s) to skip when regenerating
  -o, --output <outputDir>       directory where to put the generated files (defaults to current directory)
  -p, --param <name=value>       additional param to pass to templates
  --force-write                  force writing of the generated files to given directory even if it is a git repo with unstaged files or not empty dir (defaults to false)
  --watch-template               watches the template directory and the AsyncAPI document, and re-generate the files when changes occur. Ignores the output directory. This flag should be used only for template development.
  -h, --help                     output usage information
<summary>Click here to read more about supported values for the <template> parameter.</summary>
Templates are installable npm packages. Therefore, the value of <template> can be anything supported by npm install. Here's a summary of the possibilities:


  npm install [<@scope>/]<name>
  npm install [<@scope>/]<name>@<tag>
  npm install [<@scope>/]<name>@<version>
  npm install [<@scope>/]<name>@<version range>
  npm install <git-host>:<git-user>/<repo-name>
  npm install <git repo url>
  npm install <tarball file>
  npm install <tarball url>
  npm install <folder>

:mag: Do you want to find a template? Click here!

Examples

The shortest possible syntax:

ag asyncapi.yaml @asyncapi/html-template

Generating from a URL:

ag https://raw.githubusercontent.com/asyncapi/asyncapi/master/examples/2.0.0/streetlights.yml @asyncapi/html-template

Specify where to put the result:

ag asyncapi.yaml @asyncapi/html-template -o ./docs

Passing parameters to templates:

ag asyncapi.yaml @asyncapi/html-template -o ./docs -p title='Hello from param'

In the template you can use it like this: {{ params.title }}

Installing the template from a folder:

ag asyncapi.yaml ~/my-template

It creates a symbolic link to the target directory (~/my-template in this case).

Installing the template from a git URL:

ag asyncapi.yaml https://github.com/asyncapi/html-template.git

As a module

See API documentation.

Authoring templates

See authoring templates and the list of templates recipes.

Contributing

Read CONTRIBUTING guide.

Author

Fran Méndez (@fmvilas)

Current Tags

  • 0.51.1                                ...           latest (12 hours ago)

35 Versions

  • 0.51.1                                ...           12 hours ago
  • 0.51.0                                ...           2 days ago
  • 0.50.0                                ...           5 days ago
  • 0.49.0                                ...           6 days ago
  • 0.48.0                                ...           6 days ago
  • 0.47.0                                ...           8 days ago
  • 0.46.1                                ...           12 days ago
  • 0.46.0                                ...           13 days ago
  • 0.45.1                                ...           13 days ago
  • 0.45.0                                ...           16 days ago
  • 0.44.0                                ...           22 days ago
  • 0.43.0                                ...           22 days ago
  • 0.42.1                                ...           a month ago
  • 0.42.0                                ...           a month ago
  • 0.41.0                                ...           a month ago
  • 0.40.1                                ...           a month ago
  • 0.40.0                                ...           a month ago
  • 0.39.1                                ...           a month ago
  • 0.39.0                                ...           a month ago
  • 0.38.0                                ...           a month ago
  • 0.37.0                                ...           2 months ago
  • 0.36.5                                ...           2 months ago
  • 0.36.4                                ...           2 months ago
  • 0.36.3                                ...           2 months ago
  • 0.36.2                                ...           2 months ago
  • 0.36.1                                ...           2 months ago
  • 0.36.0                                ...           2 months ago
  • 0.35.2                                ...           2 months ago
  • 0.35.1                                ...           2 months ago
  • 0.35.0                                ...           2 months ago
  • 0.34.3                                ...           2 months ago
  • 0.34.2                                ...           2 months ago
  • 0.34.1                                ...           2 months ago
  • 0.33.0                                ...           2 months ago
  • 0.34.0                                ...           2 months ago
Maintainers (2)
Downloads
Today 8
This Week 16
This Month 176
Last Day 1
Last Week 62
Last Month 142
Dependencies (17)

Copyright 2014 - 2016 © taobao.org |