Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 1 addition & 47 deletions markdown/docs/tools/generator/installation-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,53 +25,7 @@ If you don't have either Node or Npm installed, use the [official node.js instal
If you have the correct versions installed, proceed to the CLI installation guide below. Otherwise, upgrading the Npm or Node version is lower than the recommended versions specified above.

## AsyncAPI CLI
The AsyncAPI CLI tool allows you to do many different things with the [AsyncAPI document](asyncapi-document). You can generate message-based API boilerplate code, documentation, or anything else you need as long as you specify it in your [template](template) or the existing template already supports it. To use the generator via the AsyncAPI CLI, you need to install the AsyncAPI CLI tool.

### Installation

#### Install AsyncAPI CLI using NPM

The AsyncAPI CLI is a NodeJS project, so the easiest way to install it is by using the following `npm` command:
```
npm install -g @asyncapi/cli
```

To install a specific version of the generator tool, pass the version during installation:
```
npm install -g @asyncapi/cli@{version}
```

#### MacOS
You can install in MacOS by using brew: `brew install asyncapi`.

#### Linux
You can install in Linux by using `dpkg`, a package manager for debian:
1. `curl -OL https://github.com/asyncapi/cli/releases/latest/download/asyncapi.deb`
2. `sudo dpkg -i asyncapi.deb`

#### Other operating systems
For further installation instructions for different operating systems, read the [AsyncAPI CLI documentation](https://github.com/asyncapi/cli#installation).

> **Remember:**
> Each [community-developed template](https://github.com/search?q=topic%3Aasyncapi+topic%3Agenerator+topic%3Atemplate) is dependent on a certain version of the generator for it to work correctly. Before you install the AsyncAPI CLI, check the template's `package.json` for the version of the AsyncAPI CLI your template is compatible with. Read the [versioning docs](versioning) to learn why it's important to use certain generator versions with your templates.

### Update AsyncAPI CLI
There are several reasons why you might want to update your generator version:
* You have the generator tool installed but want to use the latest released features. To upgrade to the latest version, use the command below:
```
npm install -g @asyncapi/cli
```
* If your template isn't compatible with the latest generator version, you can update it to a specific version of the generator. Check the [version you need](https://github.com/asyncapi/cli/releases) and specify the version you want by using the **@** symbol as shown in the command below:
```
npm install -g @asyncapi/cli@{version}
```
> Sometimes you have to force additional npm installation like this: `npm install -g --force @asyncapi/cli`

### Uninstall AsyncAPI CLI
To uninstall the generator, use the following command:
```
npm uninstall @asyncapi/cli -g
```
The AsyncAPI CLI tool allows you to do many different things with the [AsyncAPI document](asyncapi-document). You can generate message-based API boilerplate code, documentation, or anything else you need as long as you specify it in your [template](template) or the existing template already supports it. To use the generator via the AsyncAPI CLI, you need to install the AsyncAPI CLI tool. For the latest installation instructions, visit the official AsyncAPI CLI [installation guide](https://www.asyncapi.com/docs/tools/cli/installation).

> :memo: **Note:** To use the generator in your CI/CD pipeline to automate whatever you generate for your event-driven architecture apps, install the AsyncAPI CLI in your pipeline. If you are using GitHub Actions, use [Github Actions for Generator](https://github.com/marketplace/actions/generator-for-asyncapi-documents).

Expand Down
28 changes: 4 additions & 24 deletions markdown/docs/tools/generator/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,10 @@ There are two ways to use the generator:
- [Generator library](#using-as-a-modulepackage)

## AsyncAPI CLI
Generates whatever you want using templates compatible with AsyncAPI Generator.
```bash
USAGE
$ asyncapi generate fromTemplate [ASYNCAPI] [TEMPLATE] [-h] [-d <value>] [-i] [--debug] [-n <value>] [-o <value>] [--force-write] [-w] [-p <value>] [--map-base-url <value>]

ARGUMENTS
ASYNCAPI - Local path, url or context-name pointing to AsyncAPI file
TEMPLATE - Name of the generator template like for example @asyncapi/html-template or https://github.com/asyncapi/html-template

FLAGS
-d, --disable-hook=<value>... Disable a specific hook type or hooks from a given hook type
-h, --help Show CLI help.
-i, --install Installs the template and its dependencies (defaults to false)
-n, --no-overwrite=<value>... Glob or path of the file(s) to skip when regenerating
-o, --output=<value> Directory where to put the generated files (defaults to current directory)
-p, --param=<value>... Additional param to pass to templates
-w, --watch Watches the template directory and the AsyncAPI document, and re-generate the files when changes occur. Ignores the output directory.
--debug Enable more specific errors in the console
--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)
--map-base-url=<value> Maps all schema references from base url to local folder

EXAMPLES
$ asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template@3.0.0 --use-new-generator --param version=1.0.0 singleFile=true --output ./docs --force-write
```

### `asyncapi generate fromTemplate ASYNCAPI TEMPLATE`

Generates whatever you want using templates compatible with AsyncAPI Generator. For complete command usage and options, refer to the official [AsyncAPI CLI documentation](https://www.asyncapi.com/docs/tools/cli/usage#asyncapi-generate-fromtemplate-asyncapi-template).

All templates are installable npm packages. Therefore, the value of `template` can be anything supported by `npm install`. Here's a summary of the possibilities:
```
Expand Down
4 changes: 3 additions & 1 deletion markdown/docs/tools/generator/versioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ It is better to lock a specific version of the template and the generator if you
Generate HTML with the latest AsyncAPI CLI using the html-template.
```
npm install -g @asyncapi/cli
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template -o ./docs
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template@3.0.0 --use-new-generator
```

> AsyncAPI CLI has multiple versions of the generator, and to use the latest version, you may need to pass the `--use-new-generator` flag. For more details you can also check [asyncapi generate fromTemplate ASYNCAPI TEMPLATE](https://www.asyncapi.com/docs/tools/cli/usage#asyncapi-generate-fromtemplate-asyncapi-template)

Generate HTML using a particular version of the AsyncAPI CLI using the html-template.

```
Expand Down
Loading