title | weight |
---|---|
Usage |
40 |
The AsyncAPI CLI makes it easier to work with AsyncAPI documents.
$ npm install -g @asyncapi/cli
$ asyncapi COMMAND
running command...
$ asyncapi (--version)
@asyncapi/cli/2.8.0 linux-x64 node-v18.20.4
$ asyncapi --help [COMMAND]
USAGE
$ asyncapi COMMAND
...
asyncapi bundle
asyncapi config
asyncapi config analytics
asyncapi config context
asyncapi config context add CONTEXT-NAME SPEC-FILE-PATH
asyncapi config context current
asyncapi config context edit CONTEXT-NAME NEW-SPEC-FILE-PATH
asyncapi config context init [CONTEXT-FILE-PATH]
asyncapi config context list
asyncapi config context remove CONTEXT-NAME
asyncapi config context use CONTEXT-NAME
asyncapi config versions
asyncapi convert [SPEC-FILE]
asyncapi diff OLD NEW
asyncapi generate
asyncapi generate fromTemplate ASYNCAPI TEMPLATE
asyncapi generate models LANGUAGE FILE
asyncapi new
asyncapi new file
asyncapi new glee
asyncapi new template
asyncapi optimize [SPEC-FILE]
asyncapi start
asyncapi start studio
asyncapi validate [SPEC-FILE]
Bundle one or multiple AsyncAPI Documents and their references together.
USAGE
$ asyncapi bundle [-h] [-o <value>] [-b <value>] [-d <value>] [-x]
FLAGS
-b, --base=<value> Path to the file which will act as a base. This is required when some properties need to be
overwritten.
-d, --baseDir=<value> One relative/absolute path to directory relative to which paths to AsyncAPI Documents that
should be bundled will be resolved.
-h, --help Show CLI help.
-o, --output=<value> The output file name. Omitting this flag the result will be printed in the console.
-x, --xOrigin Pass this switch to generate properties "x-origin" that will contain historical values of
dereferenced "$ref"s.
DESCRIPTION
Bundle one or multiple AsyncAPI Documents and their references together.
EXAMPLES
$ asyncapi bundle ./asyncapi.yaml > final-asyncapi.yaml
$ asyncapi bundle ./asyncapi.yaml --output final-asyncapi.yaml
$ asyncapi bundle ./asyncapi.yaml ./features.yaml
$ asyncapi bundle ./asyncapi.yaml ./features.yaml --base ./main.yaml
$ asyncapi bundle ./asyncapi.yaml ./features.yaml --base ./main.yaml --xOrigin
$ asyncapi bundle ./asyncapi.yaml -o final-asyncapi.yaml --base ../public-api/main.yaml --baseDir ./social-media/comments-service
See code: src/commands/bundle.ts
CLI config settings
USAGE
$ asyncapi config
DESCRIPTION
CLI config settings
See code: src/commands/config/index.ts
Enable or disable analytics for metrics collection
USAGE
$ asyncapi config analytics [-h] [-d] [-e] [-s]
FLAGS
-d, --disable disable analytics
-e, --enable enable analytics
-h, --help Show CLI help.
-s, --status show current status of analytics
DESCRIPTION
Enable or disable analytics for metrics collection
See code: src/commands/config/analytics.ts
Manage short aliases for full paths to AsyncAPI documents
USAGE
$ asyncapi config context
DESCRIPTION
Manage short aliases for full paths to AsyncAPI documents
See code: src/commands/config/context/index.ts
Add a context to the store
USAGE
$ asyncapi config context add CONTEXT-NAME SPEC-FILE-PATH [-h] [-s]
ARGUMENTS
CONTEXT-NAME context name
SPEC-FILE-PATH file path of the spec file
FLAGS
-h, --help Show CLI help.
-s, --set-current Set context being added as the current context
DESCRIPTION
Add a context to the store
See code: src/commands/config/context/add.ts
Shows the current context that is being used
USAGE
$ asyncapi config context current [-h]
FLAGS
-h, --help Show CLI help.
DESCRIPTION
Shows the current context that is being used
See code: src/commands/config/context/current.ts
Edit a context in the store
USAGE
$ asyncapi config context edit CONTEXT-NAME NEW-SPEC-FILE-PATH [-h]
ARGUMENTS
CONTEXT-NAME context name
NEW-SPEC-FILE-PATH file path of the spec file
FLAGS
-h, --help Show CLI help.
DESCRIPTION
Edit a context in the store
See code: src/commands/config/context/edit.ts
Initialize context
USAGE
$ asyncapi config context init [CONTEXT-FILE-PATH] [-h]
ARGUMENTS
CONTEXT-FILE-PATH Specify directory in which context file should be created:
- current directory : asyncapi config context init . (default)
- root of current repository : asyncapi config context init ./
- user's home directory : asyncapi config context init ~
FLAGS
-h, --help Show CLI help.
DESCRIPTION
Initialize context
See code: src/commands/config/context/init.ts
List all the stored contexts in the store
USAGE
$ asyncapi config context list [-h]
FLAGS
-h, --help Show CLI help.
DESCRIPTION
List all the stored contexts in the store
See code: src/commands/config/context/list.ts
Delete a context from the store
USAGE
$ asyncapi config context remove CONTEXT-NAME [-h]
ARGUMENTS
CONTEXT-NAME Name of the context to delete
FLAGS
-h, --help Show CLI help.
DESCRIPTION
Delete a context from the store
See code: src/commands/config/context/remove.ts
Set a context as current
USAGE
$ asyncapi config context use CONTEXT-NAME [-h]
ARGUMENTS
CONTEXT-NAME name of the saved context
FLAGS
-h, --help Show CLI help.
DESCRIPTION
Set a context as current
See code: src/commands/config/context/use.ts
Show versions of AsyncAPI tools used
USAGE
$ asyncapi config versions [-h]
FLAGS
-h, --help Show CLI help.
DESCRIPTION
Show versions of AsyncAPI tools used
See code: src/commands/config/versions.ts
Convert asyncapi documents older to newer versions or OpenAPI/postman-collection documents to AsyncAPI
USAGE
$ asyncapi convert [SPEC-FILE] -f openapi|asyncapi|postman-collection [-h] [-o <value>] [-t <value>] [-p
client|server]
ARGUMENTS
SPEC-FILE spec path, url, or context-name
FLAGS
-f, --format=<option> (required) [default: asyncapi] Specify the format to convert from (openapi or asyncapi)
<options: openapi|asyncapi|postman-collection>
-h, --help Show CLI help.
-o, --output=<value> path to the file where the result is saved
-p, --perspective=<option> [default: server] Perspective to use when converting OpenAPI to AsyncAPI (client or
server). Note: This option is only applicable for OpenAPI to AsyncAPI conversions.
<options: client|server>
-t, --target-version=<value> [default: 3.0.0] asyncapi version to convert to
DESCRIPTION
Convert asyncapi documents older to newer versions or OpenAPI/postman-collection documents to AsyncAPI
See code: src/commands/convert.ts
Find diff between two asyncapi files
USAGE
$ asyncapi diff OLD NEW [-h] [-f json|yaml|yml|md] [-t breaking|non-breaking|unclassified|all]
[--markdownSubtype json|yaml|yml] [-o <value>] [--no-error] [-w] [--log-diagnostics] [--diagnostics-format
json|stylish|junit|html|text|teamcity|pretty] [--fail-severity error|warn|info|hint]
ARGUMENTS
OLD old spec path, URL or context-name
NEW new spec path, URL or context-name
FLAGS
-f, --format=<option> [default: yaml] format of the output
<options: json|yaml|yml|md>
-h, --help Show CLI help.
-o, --overrides=<value> path to JSON file containing the override properties
-t, --type=<option> [default: all] type of the output
<options: breaking|non-breaking|unclassified|all>
-w, --watch Enable watch mode
--diagnostics-format=<option> [default: stylish] format to use for validation diagnostics
<options: json|stylish|junit|html|text|teamcity|pretty>
--fail-severity=<option> [default: error] diagnostics of this level or above will trigger a failure exit
code
<options: error|warn|info|hint>
--[no-]log-diagnostics log validation diagnostics or not
--markdownSubtype=<option> the format of changes made to AsyncAPI document. It works only when diff is
generated using md type. For example, when you specify subtype as json, then diff
information in markdown is dumped as json structure.
<options: json|yaml|yml>
--no-error don't show error on breaking changes
DESCRIPTION
Find diff between two asyncapi files
See code: src/commands/diff.ts
Generate typed models or other things like clients, applications or docs using AsyncAPI Generator templates.
USAGE
$ asyncapi generate
DESCRIPTION
Generate typed models or other things like clients, applications or docs using AsyncAPI Generator templates.
See code: src/commands/generate/index.ts
Generates whatever you want using templates compatible with AsyncAPI Generator.
USAGE
$ asyncapi generate fromTemplate ASYNCAPI TEMPLATE [-h] [-d <value>...] [--no-interactive] [-i] [--debug] [-n <value>...]
[-o <value>] [--force-write] [-w] [-p <value>...] [--map-base-url <value>] [--registry-url <value>] [--registry-auth
<value>] [--registry-token <value>] [--use-new-generator]
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
--no-interactive Disable interactive mode and run with the provided flags.
--registry-auth=<value> The registry username and password encoded with base64, formatted as username:password
--registry-token=<value> The npm registry authentication token, that can be passed instead of base64 encoded
username and password
--registry-url=<value> [default: https://registry.npmjs.org] Specifies the URL of the private registry for
fetching templates and dependencies
--use-new-generator Use v2 generator, for generating from newer templates
DESCRIPTION
Generates whatever you want using templates compatible with AsyncAPI Generator.
EXAMPLES
$ 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
Generates typed models
USAGE
$ asyncapi generate models LANGUAGE FILE [-h] [-o <value>] [--packageName <value>] [--namespace <value>]
[--tsModelType class|interface] [--tsEnumType enum|union] [--tsModuleSystem ESM|CJS] [--tsIncludeComments]
[--tsExportType default|named] [--tsJsonBinPack] [--tsMarshalling] [--tsExampleInstance] [--tsRawPropertyNames]
[--csharpAutoImplement] [--csharpNewtonsoft] [--csharpArrayType Array|List] [--csharpHashcode] [--csharpEqual]
[--csharpSystemJson] [--javaIncludeComments] [--javaJackson] [--javaConstraints] [--javaArrayType Array|List]
[--pyDantic] [--no-interactive] [--log-diagnostics] [--diagnostics-format
json|stylish|junit|html|text|teamcity|pretty] [--fail-severity error|warn|info|hint]
ARGUMENTS
LANGUAGE (typescript|csharp|golang|java|javascript|dart|python|rust|kotlin|php|cplusplus|scala) The language you want
the typed models generated for.
FILE Path or URL to the AsyncAPI document, or context-name
FLAGS
-h, --help Show CLI help.
-o, --output=<value> The output directory where the models should be written to. Omitting this flag will
write the models to `stdout`.
--csharpArrayType=<option> [default: Array] C# specific, define which type of array needs to be generated.
<options: Array|List>
--csharpAutoImplement C# specific, define whether to generate auto-implemented properties or not.
--csharpEqual C# specific, generate the models with the Equal method overwritten
--csharpHashcode C# specific, generate the models with the GetHashCode method overwritten
--csharpNewtonsoft C# specific, generate the models with newtonsoft serialization support
--csharpSystemJson C# specific, generate the models with System.Text.Json serialization support
--diagnostics-format=<option> [default: stylish] format to use for validation diagnostics
<options: json|stylish|junit|html|text|teamcity|pretty>
--fail-severity=<option> [default: error] diagnostics of this level or above will trigger a failure exit
code
<options: error|warn|info|hint>
--javaArrayType=<option> [default: Array] Java specific, define which type of array needs to be generated.
<options: Array|List>
--javaConstraints Java specific, generate the models with constraints
--javaIncludeComments Java specific, if enabled add comments while generating models.
--javaJackson Java specific, generate the models with Jackson serialization support
--[no-]log-diagnostics log validation diagnostics or not
--namespace=<value> C#, C++ and PHP specific, define the namespace to use for the generated models.
This is required when language is `csharp`,`c++` or `php`.
--no-interactive Disable interactive mode and run with the provided flags.
--packageName=<value> Go, Java and Kotlin specific, define the package to use for the generated models.
This is required when language is `go`, `java` or `kotlin`.
--pyDantic Python specific, generate the Pydantic models.
--tsEnumType=<option> [default: enum] TypeScript specific, define which type of enums needs to be
generated.
<options: enum|union>
--tsExampleInstance Typescript specific, generate example of the model.
--tsExportType=<option> [default: default] TypeScript specific, define which type of export needs to be
generated.
<options: default|named>
--tsIncludeComments TypeScript specific, if enabled add comments while generating models.
--tsJsonBinPack TypeScript specific, define basic support for serializing to and from binary with
jsonbinpack.
--tsMarshalling TypeScript specific, generate the models with marshalling functions.
--tsModelType=<option> [default: class] TypeScript specific, define which type of model needs to be
generated.
<options: class|interface>
--tsModuleSystem=<option> [default: ESM] TypeScript specific, define the module system to be used.
<options: ESM|CJS>
--tsRawPropertyNames Typescript specific, generate the models using raw property names.
DESCRIPTION
Generates typed models
See code: src/commands/generate/models.ts
Creates a new asyncapi file
USAGE
$ asyncapi new [-h] [-n <value>] [-e <value>] [-s] [-p <value>] [--no-tty]
FLAGS
-e, --example=<value>
name of the example to use. Available examples are:
- simple-asyncapi.yml
- adeo-kafka-request-reply-asyncapi.yml
- anyof-asyncapi.yml
- application-headers-asyncapi.yml
- correlation-id-asyncapi.yml
- websocket-gemini-asyncapi.yml
- gitter-streaming-asyncapi.yml
- kraken-websocket-request-reply-message-filter-in-reply-asyncapi.yml
- kraken-websocket-request-reply-multiple-channels-asyncapi.yml
- mercure-asyncapi.yml
- not-asyncapi.yml
- operation-security-asyncapi.yml
- oneof-asyncapi.yml
- rpc-client-asyncapi.yml
- rpc-server-asyncapi.yml
- slack-rtm-asyncapi.yml
- tutorial.yml
- streetlights-kafka-asyncapi.yml
- streetlights-operation-security-asyncapi.yml
- streetlights-mqtt-asyncapi.yml
-h, --help
Show CLI help.
-n, --file-name=<value>
name of the file
-p, --port=<value>
port in which to start Studio
-s, --studio
open in Studio
--no-tty
do not use an interactive terminal
DESCRIPTION
Creates a new asyncapi file
EXAMPLES
$ asyncapi new - start creation of a file in interactive mode
$ 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
Creates a new asyncapi file
USAGE
$ asyncapi new file [-h] [-n <value>] [-e <value>] [-s] [-p <value>] [--no-tty]
FLAGS
-e, --example=<value>
name of the example to use. Available examples are:
- simple-asyncapi.yml
- adeo-kafka-request-reply-asyncapi.yml
- anyof-asyncapi.yml
- application-headers-asyncapi.yml
- correlation-id-asyncapi.yml
- websocket-gemini-asyncapi.yml
- gitter-streaming-asyncapi.yml
- kraken-websocket-request-reply-message-filter-in-reply-asyncapi.yml
- kraken-websocket-request-reply-multiple-channels-asyncapi.yml
- mercure-asyncapi.yml
- not-asyncapi.yml
- operation-security-asyncapi.yml
- oneof-asyncapi.yml
- rpc-client-asyncapi.yml
- rpc-server-asyncapi.yml
- slack-rtm-asyncapi.yml
- tutorial.yml
- streetlights-kafka-asyncapi.yml
- streetlights-operation-security-asyncapi.yml
- streetlights-mqtt-asyncapi.yml
-h, --help
Show CLI help.
-n, --file-name=<value>
name of the file
-p, --port=<value>
port in which to start Studio
-s, --studio
open in Studio
--no-tty
do not use an interactive terminal
DESCRIPTION
Creates a new asyncapi file
EXAMPLES
$ asyncapi new - start creation of a file in interactive mode
$ 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
Creates a new Glee project
USAGE
$ asyncapi new glee [-h] [-n <value>] [-t <value>] [-f <value>] [--force-write]
FLAGS
-f, --file=<value> The path to the AsyncAPI file for generating a Glee project.
-h, --help Show CLI help.
-n, --name=<value> [default: project] Name of the Project
-t, --template=<value> [default: default] Name of the Template
--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)
DESCRIPTION
Creates a new Glee project
See code: src/commands/new/glee.ts
Creates a new template
USAGE
$ asyncapi new template [-h] [-n <value>] [-t <value>] [-f <value>] [--force-write] [-r <value>]
FLAGS
-f, --file=<value> The path to the AsyncAPI file for generating a template.
-h, --help Show CLI help.
-n, --name=<value> [default: project] Name of the Project
-r, --renderer=<value> [default: react] Creating a template for particular engine, Its value can be either react or
nunjucks.
-t, --template=<value> [default: default] Name of the Template
--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)
DESCRIPTION
Creates a new template
See code: src/commands/new/template.ts
optimize asyncapi specification file
USAGE
$ asyncapi optimize [SPEC-FILE] [-h] [-p
remove-components|reuse-components|move-duplicates-to-components|move-all-to-components...] [-i schema...] [-o
terminal|new-file|overwrite] [--no-tty]
ARGUMENTS
SPEC-FILE spec path, url, or context-name
FLAGS
-h, --help Show CLI help.
-i, --ignore=<option>... [default: ] list of components to be ignored from the optimization process
<options: schema>
-o, --output=<option> [default: terminal] select where you want the output.
<options: terminal|new-file|overwrite>
-p, --optimization=<option>... [default: remove-components,reuse-components,move-duplicates-to-components,move-all-to
-components] select the type of optimizations that you want to apply.
<options: remove-components|reuse-components|move-duplicates-to-components|move-all-to
-components>
--no-tty do not use an interactive terminal
DESCRIPTION
optimize asyncapi specification file
EXAMPLES
$ asyncapi optimize ./asyncapi.yaml
$ asyncapi optimize ./asyncapi.yaml --no-tty
$ asyncapi optimize ./asyncapi.yaml --optimization=remove-components --optimization=reuse-components --optimization=move-all-to-components --no-tty
$ asyncapi optimize ./asyncapi.yaml --optimization=remove-components --output=terminal --no-tty
$ asyncapi optimize ./asyncapi.yaml --ignore=schema
See code: src/commands/optimize.ts
Starts AsyncAPI-related services. Currently, it supports launching the AsyncAPI Studio
USAGE
$ asyncapi start
DESCRIPTION
Starts AsyncAPI-related services. Currently, it supports launching the AsyncAPI Studio
See code: src/commands/start/index.ts
starts a new local instance of Studio
USAGE
$ asyncapi start studio [-h] [-f <value>] [-p <value>]
FLAGS
-f, --file=<value> path to the AsyncAPI file to link with Studio
-h, --help Show CLI help.
-p, --port=<value> port in which to start Studio
DESCRIPTION
starts a new local instance of Studio
See code: src/commands/start/studio.ts
validate asyncapi file
USAGE
$ asyncapi validate [SPEC-FILE] [-h] [-w] [--log-diagnostics] [--diagnostics-format
json|stylish|junit|html|text|teamcity|pretty] [--fail-severity error|warn|info|hint] [--score]
ARGUMENTS
SPEC-FILE spec path, url, or context-name
FLAGS
-h, --help Show CLI help.
-w, --watch Enable watch mode
--diagnostics-format=<option> [default: stylish] format to use for validation diagnostics
<options: json|stylish|junit|html|text|teamcity|pretty>
--fail-severity=<option> [default: error] diagnostics of this level or above will trigger a failure exit
code
<options: error|warn|info|hint>
--[no-]log-diagnostics log validation diagnostics or not
--score Compute the score of the AsyncAPI document. Scoring is based on whether the
document has description, license, server and/or channels.
DESCRIPTION
validate asyncapi file
See code: src/commands/validate.ts