Usage

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

The AsyncAPI CLI makes it easier to work with AsyncAPI documents.

Usage

1$ npm install -g @asyncapi/cli
2$ asyncapi COMMAND
3running command...
4$ asyncapi (--version)
5@asyncapi/cli/2.5.0 linux-x64 node-v18.20.4
6$ asyncapi --help [COMMAND]
7USAGE
8  $ asyncapi COMMAND
9...

Commands

asyncapi bundle

Bundle one or multiple AsyncAPI Documents and their references together.

1USAGE
2  $ asyncapi bundle [-h] [-o <value>] [-b <value>] [-d <value>] [-x]
3
4FLAGS
5  -b, --base=<value>     Path to the file which will act as a base. This is required when some properties need to be
6                         overwritten.
7  -d, --baseDir=<value>  One relative/absolute path to directory relative to which paths to AsyncAPI Documents that
8                         should be bundled will be resolved.
9  -h, --help             Show CLI help.
10  -o, --output=<value>   The output file name. Omitting this flag the result will be printed in the console.
11  -x, --xOrigin          Pass this switch to generate properties "x-origin" that will contain historical values of
12                         dereferenced "$ref"s.
13
14DESCRIPTION
15  Bundle one or multiple AsyncAPI Documents and their references together.
16
17EXAMPLES
18  $ asyncapi bundle ./asyncapi.yaml > final-asyncapi.yaml
19
20  $ asyncapi bundle ./asyncapi.yaml --output final-asyncapi.yaml
21
22  $ asyncapi bundle ./asyncapi.yaml ./features.yaml
23
24  $ asyncapi bundle ./asyncapi.yaml ./features.yaml --base ./main.yaml
25
26  $ asyncapi bundle ./asyncapi.yaml ./features.yaml --base ./main.yaml --xOrigin
27
28  $ asyncapi bundle ./asyncapi.yaml -o final-asyncapi.yaml --base ../public-api/main.yaml --baseDir ./social-media/comments-service

See code: src/commands/bundle.ts

asyncapi config

CLI config settings

1USAGE
2  $ asyncapi config
3
4DESCRIPTION
5  CLI config settings

See code: src/commands/config/index.ts

asyncapi config analytics

Enable or disable analytics for metrics collection

1USAGE
2  $ asyncapi config analytics [-h] [-d] [-e] [-s]
3
4FLAGS
5  -d, --disable  disable analytics
6  -e, --enable   enable analytics
7  -h, --help     Show CLI help.
8  -s, --status   show current status of analytics
9
10DESCRIPTION
11  Enable or disable analytics for metrics collection

See code: src/commands/config/analytics.ts

asyncapi config context

Manage short aliases for full paths to AsyncAPI documents

1USAGE
2  $ asyncapi config context
3
4DESCRIPTION
5  Manage short aliases for full paths to AsyncAPI documents

See code: src/commands/config/context/index.ts

asyncapi config context add CONTEXT-NAME SPEC-FILE-PATH

Add a context to the store

1USAGE
2  $ asyncapi config context add CONTEXT-NAME SPEC-FILE-PATH [-h] [-s]
3
4ARGUMENTS
5  CONTEXT-NAME    context name
6  SPEC-FILE-PATH  file path of the spec file
7
8FLAGS
9  -h, --help         Show CLI help.
10  -s, --set-current  Set context being added as the current context
11
12DESCRIPTION
13  Add a context to the store

See code: src/commands/config/context/add.ts

asyncapi config context current

Shows the current context that is being used

1USAGE
2  $ asyncapi config context current [-h]
3
4FLAGS
5  -h, --help  Show CLI help.
6
7DESCRIPTION
8  Shows the current context that is being used

See code: src/commands/config/context/current.ts

asyncapi config context edit CONTEXT-NAME NEW-SPEC-FILE-PATH

Edit a context in the store

1USAGE
2  $ asyncapi config context edit CONTEXT-NAME NEW-SPEC-FILE-PATH [-h]
3
4ARGUMENTS
5  CONTEXT-NAME        context name
6  NEW-SPEC-FILE-PATH  file path of the spec file
7
8FLAGS
9  -h, --help  Show CLI help.
10
11DESCRIPTION
12  Edit a context in the store

See code: src/commands/config/context/edit.ts

asyncapi config context init [CONTEXT-FILE-PATH]

Initialize context

1USAGE
2  $ asyncapi config context init [CONTEXT-FILE-PATH] [-h]
3
4ARGUMENTS
5  CONTEXT-FILE-PATH  Specify directory in which context file should be created:
6                     - current directory          : asyncapi config context init . (default)
7                     - root of current repository : asyncapi config context init ./
8                     - user's home directory      : asyncapi config context init ~
9
10FLAGS
11  -h, --help  Show CLI help.
12
13DESCRIPTION
14  Initialize context

See code: src/commands/config/context/init.ts

asyncapi config context list

List all the stored contexts in the store

1USAGE
2  $ asyncapi config context list [-h]
3
4FLAGS
5  -h, --help  Show CLI help.
6
7DESCRIPTION
8  List all the stored contexts in the store

See code: src/commands/config/context/list.ts

asyncapi config context remove CONTEXT-NAME

Delete a context from the store

1USAGE
2  $ asyncapi config context remove CONTEXT-NAME [-h]
3
4ARGUMENTS
5  CONTEXT-NAME  Name of the context to delete
6
7FLAGS
8  -h, --help  Show CLI help.
9
10DESCRIPTION
11  Delete a context from the store

See code: src/commands/config/context/remove.ts

asyncapi config context use CONTEXT-NAME

Set a context as current

1USAGE
2  $ asyncapi config context use CONTEXT-NAME [-h]
3
4ARGUMENTS
5  CONTEXT-NAME  name of the saved context
6
7FLAGS
8  -h, --help  Show CLI help.
9
10DESCRIPTION
11  Set a context as current

See code: src/commands/config/context/use.ts

asyncapi config versions

Show versions of AsyncAPI tools used

1USAGE
2  $ asyncapi config versions [-h]
3
4FLAGS
5  -h, --help  Show CLI help.
6
7DESCRIPTION
8  Show versions of AsyncAPI tools used

See code: src/commands/config/versions.ts

asyncapi convert [SPEC-FILE]

Convert asyncapi documents older to newer versions or OpenAPI/postman-collection documents to AsyncAPI

1USAGE
2  $ asyncapi convert [SPEC-FILE] -f openapi|asyncapi|postman-collection [-h] [-o <value>] [-t <value>] [-p
3    client|server]
4
5ARGUMENTS
6  SPEC-FILE  spec path, url, or context-name
7
8FLAGS
9  -f, --format=<option>         (required) [default: asyncapi] Specify the format to convert from (openapi or asyncapi)
10                                <options: openapi|asyncapi|postman-collection>
11  -h, --help                    Show CLI help.
12  -o, --output=<value>          path to the file where the result is saved
13  -p, --perspective=<option>    [default: server] Perspective to use when converting OpenAPI to AsyncAPI (client or
14                                server). Note: This option is only applicable for OpenAPI to AsyncAPI conversions.
15                                <options: client|server>
16  -t, --target-version=<value>  [default: 3.0.0] asyncapi version to convert to
17
18DESCRIPTION
19  Convert asyncapi documents older to newer versions or OpenAPI/postman-collection documents to AsyncAPI

See code: src/commands/convert.ts

asyncapi diff OLD NEW

Find diff between two asyncapi files

1USAGE
2  $ asyncapi diff OLD NEW [-h] [-f json|yaml|yml|md] [-t breaking|non-breaking|unclassified|all]
3    [--markdownSubtype json|yaml|yml] [-o <value>] [--no-error] [-w] [--log-diagnostics] [--diagnostics-format
4    json|stylish|junit|html|text|teamcity|pretty] [--fail-severity error|warn|info|hint]
5
6ARGUMENTS
7  OLD  old spec path, URL or context-name
8  NEW  new spec path, URL or context-name
9
10FLAGS
11  -f, --format=<option>              [default: yaml] format of the output
12                                     <options: json|yaml|yml|md>
13  -h, --help                         Show CLI help.
14  -o, --overrides=<value>            path to JSON file containing the override properties
15  -t, --type=<option>                [default: all] type of the output
16                                     <options: breaking|non-breaking|unclassified|all>
17  -w, --watch                        Enable watch mode
18      --diagnostics-format=<option>  [default: stylish] format to use for validation diagnostics
19                                     <options: json|stylish|junit|html|text|teamcity|pretty>
20      --fail-severity=<option>       [default: error] diagnostics of this level or above will trigger a failure exit
21                                     code
22                                     <options: error|warn|info|hint>
23      --[no-]log-diagnostics         log validation diagnostics or not
24      --markdownSubtype=<option>     the format of changes made to AsyncAPI document. It works only when diff is
25                                     generated using md type. For example, when you specify subtype as json, then diff
26                                     information in markdown is dumped as json structure.
27                                     <options: json|yaml|yml>
28      --no-error                     don't show error on breaking changes
29
30DESCRIPTION
31  Find diff between two asyncapi files

See code: src/commands/diff.ts

asyncapi generate

Generate typed models or other things like clients, applications or docs using AsyncAPI Generator templates.

1USAGE
2  $ asyncapi generate
3
4DESCRIPTION
5  Generate typed models or other things like clients, applications or docs using AsyncAPI Generator templates.

See code: src/commands/generate/index.ts

asyncapi generate fromTemplate ASYNCAPI TEMPLATE

Generates whatever you want using templates compatible with AsyncAPI Generator.

1USAGE
2  $ asyncapi generate fromTemplate ASYNCAPI TEMPLATE [-h] [-d <value>...] [--no-interactive] [-i] [--debug] [-n <value>...]
3    [-o <value>] [--force-write] [-w] [-p <value>...] [--map-base-url <value>] [--registry-url <value>] [--registry-auth
4    <value>] [--registry-token <value>] [--use-new-generator]
5
6ARGUMENTS
7  ASYNCAPI  - Local path, url or context-name pointing to AsyncAPI file
8  TEMPLATE  - Name of the generator template like for example @asyncapi/html-template or
9            https://github.com/asyncapi/html-template
10
11FLAGS
12  -d, --disable-hook=<value>...  Disable a specific hook type or hooks from a given hook type
13  -h, --help                     Show CLI help.
14  -i, --install                  Installs the template and its dependencies (defaults to false)
15  -n, --no-overwrite=<value>...  Glob or path of the file(s) to skip when regenerating
16  -o, --output=<value>           Directory where to put the generated files (defaults to current directory)
17  -p, --param=<value>...         Additional param to pass to templates
18  -w, --watch                    Watches the template directory and the AsyncAPI document, and re-generate the files
19                                 when changes occur. Ignores the output directory.
20      --debug                    Enable more specific errors in the console
21      --force-write              Force writing of the generated files to given directory even if it is a git repo with
22                                 unstaged files or not empty dir (defaults to false)
23      --map-base-url=<value>     Maps all schema references from base url to local folder
24      --no-interactive           Disable interactive mode and run with the provided flags.
25      --registry-auth=<value>    The registry username and password encoded with base64, formatted as username:password
26      --registry-token=<value>   The npm registry authentication token, that can be passed instead of base64 encoded
27                                 username and password
28      --registry-url=<value>     [default: https://registry.npmjs.org] Specifies the URL of the private registry for
29                                 fetching templates and dependencies
30      --use-new-generator        Use v2 generator, for generating from newer templates
31
32DESCRIPTION
33  Generates whatever you want using templates compatible with AsyncAPI Generator.
34
35EXAMPLES
36  $ asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template --param version=1.0.0 singleFile=true --output ./docs --force-write

See code: src/commands/generate/fromTemplate.ts

asyncapi generate models LANGUAGE FILE

Generates typed models

1USAGE
2  $ asyncapi generate models LANGUAGE FILE [-h] [-o <value>] [--packageName <value>] [--namespace <value>]
3    [--tsModelType class|interface] [--tsEnumType enum|union] [--tsModuleSystem ESM|CJS] [--tsIncludeComments]
4    [--tsExportType default|named] [--tsJsonBinPack] [--tsMarshalling] [--tsExampleInstance] [--tsRawPropertyNames]
5    [--csharpAutoImplement] [--csharpNewtonsoft] [--csharpArrayType Array|List] [--csharpHashcode] [--csharpEqual]
6    [--csharpSystemJson] [--javaIncludeComments] [--javaJackson] [--javaConstraints] [--javaArrayType Array|List]
7    [--pyDantic] [--no-interactive] [--log-diagnostics] [--diagnostics-format
8    json|stylish|junit|html|text|teamcity|pretty] [--fail-severity error|warn|info|hint]
9
10ARGUMENTS
11  LANGUAGE  (typescript|csharp|golang|java|javascript|dart|python|rust|kotlin|php|cplusplus|scala) The language you want
12            the typed models generated for.
13  FILE      Path or URL to the AsyncAPI document, or context-name
14
15FLAGS
16  -h, --help                         Show CLI help.
17  -o, --output=<value>               The output directory where the models should be written to. Omitting this flag will
18                                     write the models to `stdout`.
19      --csharpArrayType=<option>     [default: Array] C# specific, define which type of array needs to be generated.
20                                     <options: Array|List>
21      --csharpAutoImplement          C# specific, define whether to generate auto-implemented properties or not.
22      --csharpEqual                  C# specific, generate the models with the Equal method overwritten
23      --csharpHashcode               C# specific, generate the models with the GetHashCode method overwritten
24      --csharpNewtonsoft             C# specific, generate the models with newtonsoft serialization support
25      --csharpSystemJson             C# specific, generate the models with System.Text.Json serialization support
26      --diagnostics-format=<option>  [default: stylish] format to use for validation diagnostics
27                                     <options: json|stylish|junit|html|text|teamcity|pretty>
28      --fail-severity=<option>       [default: error] diagnostics of this level or above will trigger a failure exit
29                                     code
30                                     <options: error|warn|info|hint>
31      --javaArrayType=<option>       [default: Array] Java specific, define which type of array needs to be generated.
32                                     <options: Array|List>
33      --javaConstraints              Java specific, generate the models with constraints
34      --javaIncludeComments          Java specific, if enabled add comments while generating models.
35      --javaJackson                  Java specific, generate the models with Jackson serialization support
36      --[no-]log-diagnostics         log validation diagnostics or not
37      --namespace=<value>            C#, C++ and PHP specific, define the namespace to use for the generated models.
38                                     This is required when language is `csharp`,`c++` or `php`.
39      --no-interactive               Disable interactive mode and run with the provided flags.
40      --packageName=<value>          Go, Java and Kotlin specific, define the package to use for the generated models.
41                                     This is required when language is `go`, `java` or `kotlin`.
42      --pyDantic                     Python specific, generate the Pydantic models.
43      --tsEnumType=<option>          [default: enum] TypeScript specific, define which type of enums needs to be
44                                     generated.
45                                     <options: enum|union>
46      --tsExampleInstance            Typescript specific, generate example of the model.
47      --tsExportType=<option>        [default: default] TypeScript specific, define which type of export needs to be
48                                     generated.
49                                     <options: default|named>
50      --tsIncludeComments            TypeScript specific, if enabled add comments while generating models.
51      --tsJsonBinPack                TypeScript specific, define basic support for serializing to and from binary with
52                                     jsonbinpack.
53      --tsMarshalling                TypeScript specific, generate the models with marshalling functions.
54      --tsModelType=<option>         [default: class] TypeScript specific, define which type of model needs to be
55                                     generated.
56                                     <options: class|interface>
57      --tsModuleSystem=<option>      [default: ESM] TypeScript specific, define the module system to be used.
58                                     <options: ESM|CJS>
59      --tsRawPropertyNames           Typescript specific, generate the models using raw property names.
60
61DESCRIPTION
62  Generates typed models

See code: src/commands/generate/models.ts

asyncapi new

Creates a new asyncapi file

1USAGE
2  $ asyncapi new [-h] [-n <value>] [-e <value>] [-s] [-p <value>] [--no-tty]
3
4FLAGS
5  -e, --example=<value>
6      name of the example to use. Available examples are:
7      - simple-asyncapi.yml
8      - adeo-kafka-request-reply-asyncapi.yml
9      - anyof-asyncapi.yml
10      - application-headers-asyncapi.yml
11      - correlation-id-asyncapi.yml
12      - websocket-gemini-asyncapi.yml
13      - gitter-streaming-asyncapi.yml
14      - kraken-websocket-request-reply-message-filter-in-reply-asyncapi.yml
15      - kraken-websocket-request-reply-multiple-channels-asyncapi.yml
16      - mercure-asyncapi.yml
17      - not-asyncapi.yml
18      - operation-security-asyncapi.yml
19      - oneof-asyncapi.yml
20      - rpc-client-asyncapi.yml
21      - rpc-server-asyncapi.yml
22      - slack-rtm-asyncapi.yml
23      - tutorial.yml
24      - streetlights-kafka-asyncapi.yml
25      - streetlights-operation-security-asyncapi.yml
26      - streetlights-mqtt-asyncapi.yml
27
28  -h, --help
29      Show CLI help.
30
31  -n, --file-name=<value>
32      name of the file
33
34  -p, --port=<value>
35      port in which to start Studio
36
37  -s, --studio
38      open in Studio
39
40  --no-tty
41      do not use an interactive terminal
42
43DESCRIPTION
44  Creates a new asyncapi file
45
46EXAMPLES
47  $ asyncapi new	 - start creation of a file in interactive mode
48
49  $ asyncapi new --file-name=my-asyncapi.yml --example=default-example.yml --no-tty	 - create a new file with a specific name, using one of the examples and without interactive mode

See code: src/commands/new/index.ts

asyncapi new file

Creates a new asyncapi file

1USAGE
2  $ asyncapi new file [-h] [-n <value>] [-e <value>] [-s] [-p <value>] [--no-tty]
3
4FLAGS
5  -e, --example=<value>
6      name of the example to use. Available examples are:
7      - simple-asyncapi.yml
8      - adeo-kafka-request-reply-asyncapi.yml
9      - anyof-asyncapi.yml
10      - application-headers-asyncapi.yml
11      - correlation-id-asyncapi.yml
12      - websocket-gemini-asyncapi.yml
13      - gitter-streaming-asyncapi.yml
14      - kraken-websocket-request-reply-message-filter-in-reply-asyncapi.yml
15      - kraken-websocket-request-reply-multiple-channels-asyncapi.yml
16      - mercure-asyncapi.yml
17      - not-asyncapi.yml
18      - operation-security-asyncapi.yml
19      - oneof-asyncapi.yml
20      - rpc-client-asyncapi.yml
21      - rpc-server-asyncapi.yml
22      - slack-rtm-asyncapi.yml
23      - tutorial.yml
24      - streetlights-kafka-asyncapi.yml
25      - streetlights-operation-security-asyncapi.yml
26      - streetlights-mqtt-asyncapi.yml
27
28  -h, --help
29      Show CLI help.
30
31  -n, --file-name=<value>
32      name of the file
33
34  -p, --port=<value>
35      port in which to start Studio
36
37  -s, --studio
38      open in Studio
39
40  --no-tty
41      do not use an interactive terminal
42
43DESCRIPTION
44  Creates a new asyncapi file
45
46EXAMPLES
47  $ asyncapi new	 - start creation of a file in interactive mode
48
49  $ asyncapi new --file-name=my-asyncapi.yml --example=default-example.yml --no-tty	 - create a new file with a specific name, using one of the examples and without interactive mode

See code: src/commands/new/file.ts

asyncapi new glee

Creates a new Glee project

1USAGE
2  $ asyncapi new glee [-h] [-n <value>] [-t <value>] [-f <value>] [--force-write]
3
4FLAGS
5  -f, --file=<value>      The path to the AsyncAPI file for generating a Glee project.
6  -h, --help              Show CLI help.
7  -n, --name=<value>      [default: project] Name of the Project
8  -t, --template=<value>  [default: default] Name of the Template
9      --force-write       Force writing of the generated files to given directory even if it is a git repo with unstaged
10                          files or not empty dir (defaults to false)
11
12DESCRIPTION
13  Creates a new Glee project

See code: src/commands/new/glee.ts

asyncapi new template

Creates a new template

1USAGE
2  $ asyncapi new template [-h] [-n <value>] [-t <value>] [-f <value>] [--force-write] [-r <value>]
3
4FLAGS
5  -f, --file=<value>      The path to the AsyncAPI file for generating a template.
6  -h, --help              Show CLI help.
7  -n, --name=<value>      [default: project] Name of the Project
8  -r, --renderer=<value>  [default: react] Creating a template for particular engine, Its value can be either react or
9                          nunjucks.
10  -t, --template=<value>  [default: default] Name of the Template
11      --force-write       Force writing of the generated files to given directory even if it is a git repo with unstaged
12                          files or not empty dir (defaults to false)
13
14DESCRIPTION
15  Creates a new template

See code: src/commands/new/template.ts

asyncapi optimize [SPEC-FILE]

optimize asyncapi specification file

1USAGE
2  $ asyncapi optimize [SPEC-FILE] [-h] [-p
3    remove-components|reuse-components|move-duplicates-to-components|move-all-to-components...] [-i schema...] [-o
4    terminal|new-file|overwrite] [--no-tty]
5
6ARGUMENTS
7  SPEC-FILE  spec path, url, or context-name
8
9FLAGS
10  -h, --help                      Show CLI help.
11  -i, --ignore=<option>...        [default: ] list of components to be ignored from the optimization process
12                                  <options: schema>
13  -o, --output=<option>           [default: terminal] select where you want the output.
14                                  <options: terminal|new-file|overwrite>
15  -p, --optimization=<option>...  [default: remove-components,reuse-components,move-duplicates-to-components,move-all-to
16                                  -components] select the type of optimizations that you want to apply.
17                                  <options: remove-components|reuse-components|move-duplicates-to-components|move-all-to
18                                  -components>
19      --no-tty                    do not use an interactive terminal
20
21DESCRIPTION
22  optimize asyncapi specification file
23
24EXAMPLES
25  $ asyncapi optimize ./asyncapi.yaml
26
27  $ asyncapi optimize ./asyncapi.yaml --no-tty
28
29  $ asyncapi optimize ./asyncapi.yaml --optimization=remove-components --optimization=reuse-components --optimization=move-all-to-components --no-tty
30
31  $ asyncapi optimize ./asyncapi.yaml --optimization=remove-components --output=terminal --no-tty
32
33  $ asyncapi optimize ./asyncapi.yaml --ignore=schema

See code: src/commands/optimize.ts

asyncapi start

1USAGE
2  $ asyncapi start

DESCRIPTION main command for starting asyncapi services, currently studio only.

See code: src/commands/start/index.ts

asyncapi start studio

starts a new local instance of Studio

1USAGE
2  $ asyncapi start studio [-h] [-f <value>] [-p <value>]
3
4FLAGS
5  -f, --file=<value>  path to the AsyncAPI file to link with Studio
6  -h, --help          Show CLI help.
7  -p, --port=<value>  port in which to start Studio
8
9DESCRIPTION
10  starts a new local instance of Studio

See code: src/commands/start/studio.ts

asyncapi validate [SPEC-FILE]

validate asyncapi file

1USAGE
2  $ asyncapi validate [SPEC-FILE] [-h] [-w] [--log-diagnostics] [--diagnostics-format
3    json|stylish|junit|html|text|teamcity|pretty] [--fail-severity error|warn|info|hint] [--score]
4
5ARGUMENTS
6  SPEC-FILE  spec path, url, or context-name
7
8FLAGS
9  -h, --help                         Show CLI help.
10  -w, --watch                        Enable watch mode
11      --diagnostics-format=<option>  [default: stylish] format to use for validation diagnostics
12                                     <options: json|stylish|junit|html|text|teamcity|pretty>
13      --fail-severity=<option>       [default: error] diagnostics of this level or above will trigger a failure exit
14                                     code
15                                     <options: error|warn|info|hint>
16      --[no-]log-diagnostics         log validation diagnostics or not
17      --score                        Compute the score of the AsyncAPI document. Scoring is based on whether the
18                                     document has description, license, server and/or channels.
19
20DESCRIPTION
21  validate asyncapi file

See code: src/commands/validate.ts

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