### Install and Run AsyncAPI Server Locally Source: https://github.com/asyncapi/cli/blob/master/src/apps/api/README.md Install project dependencies and start the server locally. The server will be accessible at http://localhost:80. ```bash npm install npm run api:prod ``` -------------------------------- ### Install and Run AsyncAPI CLI Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Install the AsyncAPI CLI globally using npm and run commands. This is the basic setup for using the CLI. ```sh $ npm install -g @asyncapi/cli $ asyncapi COMMAND ``` ```sh $ asyncapi (--version|--v) @asyncapi/cli/5.0.7 darwin-arm64 node-v24.7.0 ``` ```sh $ asyncapi --help [COMMAND] USAGE $ asyncapi COMMAND ... ``` -------------------------------- ### Setup and Pre-PR Checks Source: https://github.com/asyncapi/cli/blob/master/docs/contributing-prs.md Install dependencies, set up lefthook, and run build, lint, and test commands before submitting a pull request. ```bash # Setup npm install && npx lefthook install # Before PR npm run build && npm run lint && npm run cli:test ``` -------------------------------- ### Install Template Dependencies Source: https://github.com/asyncapi/cli/blob/master/assets/create-template/templates/default/readme.md Run this command to install all necessary dependencies before using a template. ```bash npm install ``` -------------------------------- ### Install AsyncAPI CLI Source: https://context7.com/asyncapi/cli/llms.txt Install the AsyncAPI CLI globally using npm, Homebrew, or Docker. Verify the installation by checking the version. ```sh # npm (requires Node.js >= 24) npm install -g @asyncapi/cli ``` ```sh # Homebrew (macOS) brew install asyncapi ``` ```sh # Chocolatey (Windows) choco install asyncapi ``` ```sh # Docker – mount your spec and output directories docker run --rm -it \ --user=root \ -v /path/to/asyncapi.yaml:/app/asyncapi.yml \ -v /path/to/output:/app/output \ asyncapi/cli generate fromTemplate /app/asyncapi.yml @asyncapi/html-template --force-write ``` ```sh # Verify installation asyncapi --version # @asyncapi/cli/6.0.0 linux-x64 node-v24.7.0 ``` -------------------------------- ### AsyncAPI Autocomplete Installation Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Display installation instructions for shell autocompletion. Specify the shell type (zsh, bash, powershell) to get specific instructions. Use the --refresh-cache flag to update the autocomplete cache. ```sh USAGE $ asyncapi autocomplete [SHELL] [-r] ARGUMENTS [SHELL] (zsh|bash|powershell) Shell type FLAGS -r, --refresh-cache Refresh cache (ignores displaying instructions) DESCRIPTION Display autocomplete installation instructions. EXAMPLES $ asyncapi autocomplete $ asyncapi autocomplete bash $ asyncapi autocomplete zsh $ asyncapi autocomplete powershell $ asyncapi autocomplete --refresh-cache ``` -------------------------------- ### Install AsyncAPI CLI with npm Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Install the AsyncAPI CLI globally using npm after ensuring Node.js and npm are set up. ```bash npm install -g @asyncapi/cli ``` -------------------------------- ### Example Context File Configuration Source: https://github.com/asyncapi/cli/blob/master/docs/context.md An example of a complete AsyncAPI context configuration file. It defines a 'current' context named 'monitor' and maps context names like 'monitor', 'notifier', and 'subscriber' to their respective AsyncAPI file paths. ```json { "current": "monitor", "store": { "monitor": "monitor/asyncapi.yaml", "notifier": "notifier/asyncapi.yaml", "subscriber": "subscriber/asyncapi.yaml" } } ``` -------------------------------- ### Install AsyncAPI CLI from macOS pkg file Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Install the downloaded AsyncAPI CLI macOS package using the installer command. ```bash sudo installer -pkg asyncapi.pkg -target / ``` -------------------------------- ### Example Docker Run Command Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md An example of running the AsyncAPI CLI with Docker, specifying volume mounts for a local AsyncAPI file and output directory. ```bash docker run --rm -it \ --user=root \ -v ${PWD}/test/integration/fixtures/asyncapi_v1.yml:/app/asyncapi.yml \ -v ${PWD}/output:/app/output \ asyncapi-cli generate fromTemplate -o /app/output /app/asyncapi.yml @asyncapi/html-template --force-write ``` -------------------------------- ### Start AsyncAPI Studio in Preview Mode Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Starts a local instance of AsyncAPI Studio in a minimal state for previewing. This mode bundles all schema file references and disallows editing. It supports options for specifying the port, base file, base directory, and controlling browser auto-launch or log suppression. ```bash asyncapi start preview SPEC-FILE [-h] [-p ] [-b ] [-d ] [-x] [-l] [-B] ``` -------------------------------- ### Install Homebrew and AsyncAPI CLI on macOS Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Install the Homebrew package manager and then use it to install the AsyncAPI CLI on macOS. ```bash # Install brew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # Install AsyncAPI CLI brew install asyncapi ``` -------------------------------- ### Verify AsyncAPI CLI Installation Source: https://github.com/asyncapi/cli/blob/master/docs/autocompleteEnabled.md Check if the AsyncAPI CLI is installed by verifying its version. If not installed, this command shows how to install it globally. ```sh asyncapi --version ``` ```sh npm install -g @asyncapi/cli ``` -------------------------------- ### Start AsyncAPI Services Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Starts AsyncAPI-related services. Currently, this command is used to launch the AsyncAPI Studio. ```bash asyncapi start ``` -------------------------------- ### Download AsyncAPI CLI macOS Installer (x64) Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Download the macOS installer package for the AsyncAPI CLI for x64 architecture using curl. ```bash curl -OL https://github.com/asyncapi/cli/releases/latest/download/asyncapi.x64.pkg ``` -------------------------------- ### Build AsyncAPI CLI Locally Source: https://github.com/asyncapi/cli/blob/master/docs/autocompleteEnabled.md If working with the CLI project locally, build the project first using npm install and npm run build before proceeding with manual setup. ```sh npm install ``` ```sh npm run build ``` -------------------------------- ### Download AsyncAPI CLI Executable for Windows (x64) Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Download the 64-bit Windows executable installer for the AsyncAPI CLI. ```bash https://github.com/asyncapi/cli/releases/latest/download/asyncapi.x64.exe ``` -------------------------------- ### Test Project Setup Source: https://github.com/asyncapi/cli/blob/master/README.md Run tests to ensure the development environment is correctly set up for the AsyncAPI CLI project. ```bash npm run test ``` -------------------------------- ### Download AsyncAPI CLI Executable for Windows (x86) Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Download the 32-bit Windows executable installer for the AsyncAPI CLI. ```bash https://github.com/asyncapi/cli/releases/latest/download/asyncapi.x86.exe ``` -------------------------------- ### AsyncAPI CLI Autocomplete Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Display autocomplete installation instructions for various shells. ```APIDOC ## asyncapi autocomplete [SHELL] ### Description Display autocomplete installation instructions. ### Method CLI Command ### Endpoint N/A ### Parameters #### Path Parameters - **SHELL** (string) - Optional - Shell type (zsh|bash|powershell) #### Query Parameters - **--refresh-cache** (boolean) - Optional - Refresh cache (ignores displaying instructions) ### Request Example ```sh $ asyncapi autocomplete $ asyncapi autocomplete bash ``` ### Response #### Success Response Autocomplete installation instructions for the specified shell. #### Response Example ```sh # Example output for bash # To activate completions for each session, add the following to your bash profile: # eval "$(asyncapi autocomplete bash)" # To load completions immediately, run: # eval "$(asyncapi autocomplete bash)" ``` ``` -------------------------------- ### Download AsyncAPI CLI macOS Installer (arm64) Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Download the macOS installer package for the AsyncAPI CLI for arm64 architecture using curl. ```bash curl -OL https://github.com/asyncapi/cli/releases/latest/download/asyncapi.arm64.pkg ``` -------------------------------- ### Check Node and npm Installation Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Verify if Node.js and npm are installed on your system. Ensure Node.js version is 16 or higher. ```bash # check if node is installed node -v # or node --version # check if NPM is installed npm -v # or npm --version ``` -------------------------------- ### Start AsyncAPI Studio Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Launches the AsyncAPI Studio for local development. You can specify an AsyncAPI file to link with Studio using the --file flag or by providing it as an argument. The --port flag can be used to set the Studio port. ```bash asyncapi start studio [SPEC-FILE] ``` ```bash asyncapi start studio [SPEC-FILE] [-h] [-f ] [-p ] [--no-interactive] [-B] ``` -------------------------------- ### Start API Server in Development Mode Source: https://github.com/asyncapi/cli/blob/master/docs/debugging-testing.md Launch the API server with hot-reloading enabled for rapid development. Alternatively, start it manually with debugging flags. ```bash # Start with hot-reload npm run api:dev # Or manually with debugging NODE_ENV=development DEBUG=* node ./lib/apps/api/server.js ``` -------------------------------- ### Install AsyncAPI CLI with Chocolatey on Windows Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Install the AsyncAPI CLI globally on Windows using the Chocolatey package manager. Requires administrator privileges. ```powershell choco install asyncapi ``` -------------------------------- ### Launch AsyncAPI Studio Source: https://context7.com/asyncapi/cli/llms.txt Start a local instance of AsyncAPI Studio, a browser-based editor. Optionally pre-load a specific AsyncAPI document, specify a custom port, or disable automatic browser opening. ```bash asyncapi start studio ``` ```bash asyncapi start studio ./asyncapi.yaml ``` ```bash asyncapi start studio ./asyncapi.yaml --port 8080 --noBrowser ``` ```bash asyncapi start studio --file ./docs/api/asyncapi.yaml --port 4000 ``` -------------------------------- ### Package Version Update Example Source: https://github.com/asyncapi/cli/blob/master/DEVELOPMENT.md Illustrates the change in package version during the release process, before and after the update. ```json "name": "@asyncapi/cli", "version": "2.0.1", ``` ```json "name": "@asyncapi/cli", "version": "3.0.1", ``` -------------------------------- ### Download Specific AsyncAPI CLI macOS Installer Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Download a specific version of the AsyncAPI CLI macOS installer package using curl. ```bash curl -OL https://github.com/asyncapi/cli/releases/download//asyncapi.pkg ``` -------------------------------- ### Create New AsyncAPI Project Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Use this command to start a new AsyncAPI project, generate specification files, or create templates for clients and applications. It can be run interactively. ```bash asyncapi new ``` -------------------------------- ### Build AsyncAPI CLI Docker Image Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Build a Docker image for the AsyncAPI CLI. Ensure Docker is installed first. ```bash docker build -t asyncapi/cli:latest . ``` -------------------------------- ### Set up AsyncAPI CLI Symlink Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Steps to create a symbolic link for the AsyncAPI CLI to be executable from any directory. This involves navigating into the extracted directory, getting the absolute path, and creating the symlink in a directory like `/user/local/bin`. ```bash # cd into the unarchived directory cd asyncapi # get the absolute path pwd # Create a symlink ln -s /bin/asyncapi /user/local/bin/asyncapi # The "asyncapi" command should be available to be used asyncapi ``` -------------------------------- ### Example 'action.invoked' Metric Data Source: https://github.com/asyncapi/cli/blob/master/docs/metrics_collection.md Illustrates the data format for tracking command invocation, showing the action performed. ```text asyncapi_adoption.action.invoked COUNTER { action: 'validate' } 1 ``` -------------------------------- ### AsyncAPI CLI GitHub Action - Basic Usage Source: https://github.com/asyncapi/cli/blob/master/docs/github-action.md This is a basic setup for the AsyncAPI CLI GitHub Action. It uses default values for all inputs, typically generating Markdown documentation from an `asyncapi.yaml` file in the repository root. ```yaml - name: Generating Markdown from my AsyncAPI document uses: asyncapi/cli@v2.16.0 # You can use any version you want ``` -------------------------------- ### Install Specific AsyncAPI CLI Version with Chocolatey Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Install a specific version of the AsyncAPI CLI on Windows using Chocolatey by providing the version number. ```powershell choco install asyncapi --version xx.xx.xx ``` -------------------------------- ### Minimal Empty Context File Source: https://github.com/asyncapi/cli/blob/master/docs/context.md A minimal AsyncAPI context configuration file containing only the required 'store' object, which is an empty map. This is a valid starting point for a new context configuration. ```json { "store": {} } ``` -------------------------------- ### Generate API Client in JavaScript and Python Source: https://context7.com/asyncapi/cli/llms.txt Generates a full API client for a given language using AsyncAPI Generator templates. Supports languages like Dart, Java, JavaScript, and Python. Use --param to pass template-specific parameters and --install to include template dependency installation. ```sh # Generate a JavaScript client into ./client asyncapi generate client javascript asyncapi.yaml \ --param version=1.0.0 singleFile=true \ --output ./client \ --force-write ``` ```sh # Generate a Python client, installing template dependencies asyncapi generate client python asyncapi.yaml \ --install \ --output ./client ``` ```sh # Watch mode for active development asyncapi generate client javascript asyncapi.yaml \ --output ./client \ --watch ``` -------------------------------- ### Example 'action.finished' Metric Data Source: https://github.com/asyncapi/cli/blob/master/docs/metrics_collection.md Shows the data collected when a command finishes, including execution results and document metadata. ```text asyncapi_adoption.action.finished COUNTER { validation_result: 'valid', success: true, asyncapi_version: '2.6.0', asyncapi_servers: 2, asyncapi_channels: 4, asyncapi_messages: 3, asyncapi_operations_send: 3, asyncapi_operations_receive: 1, asyncapi_schemas: 52, action: 'validate' } 1 ``` -------------------------------- ### Start AsyncAPI Server API Source: https://context7.com/asyncapi/cli/llms.txt Launch the AsyncAPI HTTP server API, which exposes CLI functionality over REST endpoints. Supports different modes (production, development, test) and custom ports. ```bash asyncapi start api ``` ```bash asyncapi start api --mode development --port 3000 ``` ```bash asyncapi start api --mode test --port 3001 ``` -------------------------------- ### Run AsyncAPI CLI Autocomplete Command Manually Source: https://github.com/asyncapi/cli/blob/master/docs/autocompleteEnabled.md Execute the autocomplete command directly from the project root to generate the necessary script for manual setup. ```sh ./bin/run autocomplete # Run this from the project root folder ``` -------------------------------- ### Apply Bash and Zsh Autocomplete Changes Source: https://github.com/asyncapi/cli/blob/master/docs/autocompleteEnabled.md After installation, source your shell's configuration file to apply the autocomplete changes. This is necessary for both bash and zsh. ```sh source ~/.bashrc # For bash ``` ```sh source ~/.zshrc # For zsh ``` -------------------------------- ### Create New AsyncAPI File Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Generates a new AsyncAPI file. You can specify the file name, use an example template, and choose whether to run in interactive mode or not. It can also open the file in Studio. ```bash asyncapi new file [-h] [-n ] [-e ] [-s] [-p ] [--no-tty] ``` ```bash asyncapi new - start creation of a file in interactive mode ``` ```bash asyncapi new --file-name=my-asyncapi.yaml --example=default-example.yaml --no-tty - create a new file with a specific name, using one of the examples and without interactive mode ``` -------------------------------- ### AsyncAPI CLI GitHub Actions Integration Source: https://context7.com/asyncapi/cli/llms.txt Example of using the AsyncAPI CLI as a GitHub Action for CI/CD pipelines. Enables automated validation, generation, and conversion on code changes. ```yaml ... ``` -------------------------------- ### Create New AsyncAPI File Source: https://context7.com/asyncapi/cli/llms.txt Scaffold a new AsyncAPI specification file. Supports interactive mode for prompts or non-interactive mode with specified file name and example template. Can also open directly in Studio. ```bash asyncapi new file ``` ```bash asyncapi new file \ --file-name my-api.yaml \ --example streetlights-kafka-asyncapi.yml \ --no-tty ``` ```bash asyncapi new file --studio ``` -------------------------------- ### Initialize Context File Source: https://github.com/asyncapi/cli/blob/master/docs/context.md Initializes a new '.asyncapi-cli' context file in the current directory. This file stores your context configurations. ```bash asyncapi config context init Initialized context /amadeus-async-flight-status/.asyncapi-cli ``` -------------------------------- ### Build and Run CLI Command Interactively Source: https://github.com/asyncapi/cli/blob/master/docs/debugging-testing.md Build the project and immediately execute a CLI command with specified arguments. ```bash # Build and run immediately npm run build && ./bin/run validate ./test/fixtures/specification.yml ``` -------------------------------- ### Full Workflow: Generate HTML and Deploy to GitHub Pages Source: https://github.com/asyncapi/cli/blob/master/docs/github-action.md This workflow generates HTML documentation from an AsyncAPI file using a custom template and then deploys the generated HTML to GitHub Pages. It includes checking out the repository and using a separate action for deployment. ```yaml name: AsyncAPI documents processing on: push: branches: [ master ] jobs: generate: runs-on: ubuntu-latest steps: #"standard step" where repo needs to be checked-out first - name: Checkout repo uses: actions/checkout@v2 #In case you do not want to use defaults, you for example want to use different template - name: Generating HTML from my AsyncAPI document uses: asyncapi/cli@v2.16.0 # You can use any version you want with: template: '@asyncapi/html-template@0.9.0' #In case of template from npm, because of @ it must be in quotes filepath: docs/api/my-asyncapi.yml parameters: -p baseHref=/test-experiment/ sidebarOrganization=byTags #space separated list of key/values output: generated-html #Using another action that takes generated HTML and pushes it to GH Pages - name: Deploy GH page uses: JamesIves/github-pages-deploy-action@3.4.2 with: ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} BRANCH: gh-pages FOLDER: generated-html ``` -------------------------------- ### List All Contexts Source: https://github.com/asyncapi/cli/blob/master/docs/context.md Display a list of all configured contexts and their associated AsyncAPI file paths. This helps in managing and understanding your project configurations. ```bash (main)$ asyncapi config context list monitor: monitor/asyncapi.yaml notifier: notifier/asyncapi.yaml subscriber: subscriber/asyncapi.yaml ``` -------------------------------- ### Preview AsyncAPI Spec in Studio Source: https://context7.com/asyncapi/cli/llms.txt Launch a read-only preview of a bundled AsyncAPI specification in Studio. This resolves all `$ref` references and is useful for sharing or reviewing fully resolved documents. Options include custom ports, suppressing logs, and disabling the auto-opening browser. ```bash asyncapi start preview ./asyncapi.yaml ``` ```bash asyncapi start preview ./asyncapi.yaml --port 9000 --suppressLogs ``` ```bash asyncapi start preview ./asyncapi.yaml --noBrowser ``` ```bash asyncapi start preview ./asyncapi.yaml \ --base ./main.yaml \ --baseDir ./services/comments \ --xOrigin ``` -------------------------------- ### Initialize Context Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Initializes a new context file in the specified directory. ```APIDOC ## `asyncapi config context init [CONTEXT-FILE-PATH]` ### Description Initialize context ### Arguments - `CONTEXT-FILE-PATH` (string): Specify directory in which context file should be created. Defaults to current directory. ### Flags - `-h`, `--help`: Show CLI help. ``` -------------------------------- ### Upgrade AsyncAPI CLI with Chocolatey on Windows Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Upgrade an existing installation of the AsyncAPI CLI to the latest version using Chocolatey. ```powershell choco upgrade asyncapi ``` -------------------------------- ### Generate Client with Parameters Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Use this command to generate a client for a specific language, passing custom parameters and specifying output options. The `--force-write` flag ensures files are written even if the output directory is not empty. ```bash asyncapi generate client javascript asyncapi.yaml --param version=1.0.0 singleFile=true --output ./docs --force-write ``` -------------------------------- ### Conventional Commit Example Source: https://github.com/asyncapi/cli/blob/master/DEVELOPMENT.md Use conventional commits for clear git history. The 'feat' and 'fix' prefixes are essential for triggering releases. ```git feat: add new feature ``` -------------------------------- ### Run Tests in Watch Mode Source: https://github.com/asyncapi/cli/blob/master/docs/debugging-testing.md Develop with automatic test re-runs using nodemon. After starting the dev server, run unit tests manually. ```bash # Using nodemon for file watching npm run dev # Then run tests manually when needed npm run unit:test ``` -------------------------------- ### Debug CLI Commands with Node.js Inspector Source: https://github.com/asyncapi/cli/blob/master/docs/debugging-testing.md Start the CLI with the Node.js inspector enabled to attach a debugger. Access Chrome DevTools via chrome://inspect. ```bash # Start with Node inspector node --inspect-brk ./bin/run validate ./path/to/asyncapi.yml # Then open Chrome DevTools at: chrome://inspect ``` -------------------------------- ### Initialize Terraform Project Source: https://github.com/asyncapi/cli/blob/master/src/apps/api/README.md Initialize the Terraform project for deployment. This command should be run from the ./deployments/apps directory. ```bash terraform init ``` -------------------------------- ### Enable Shell Autocomplete for AsyncAPI CLI Source: https://context7.com/asyncapi/cli/llms.txt Installs tab-completion for AsyncAPI commands and flags into your shell profile. Supports bash, zsh, and PowerShell. Remember to refresh the cache after upgrades. ```bash asyncapi autocomplete ``` ```bash asyncapi autocomplete bash ``` ```bash asyncapi autocomplete zsh ``` ```bash asyncapi autocomplete powershell ``` ```bash asyncapi autocomplete --refresh-cache ``` ```bash source ~/.zshrc # zsh source ~/.bashrc # bash ``` -------------------------------- ### Run Local CLI Build Source: https://github.com/asyncapi/cli/blob/master/README.md Build the CLI project and then execute it locally using the generated binary. This is useful for testing local changes. ```bash npm run build bin/run ``` -------------------------------- ### Unit Test Structure Source: https://github.com/asyncapi/cli/blob/master/docs/debugging-testing.md Standard structure for unit tests using Chai. Includes setup with `beforeEach` and describes test cases for methods with arrange, act, and assert phases. ```typescript // test/unit/services/my-service.test.ts import { expect } from 'chai'; import { MyService } from '../../../src/domains/services/my.service'; describe('MyService', () => { let service: MyService; beforeEach(() => { service = new MyService(); }); describe('methodName', () => { it('should do something when given valid input', async () => { // Arrange const input = { /* test data */ }; // Act const result = await service.methodName(input); // Assert expect(result.success).to.be.true; expect(result.data).to.exist; }); it('should handle errors gracefully', async () => { // Arrange const invalidInput = null; // Act const result = await service.methodName(invalidInput); // Assert expect(result.success).to.be.false; expect(result.error).to.include('error message'); }); }); }); ``` -------------------------------- ### Initialize and Manage AsyncAPI CLI Contexts Source: https://context7.com/asyncapi/cli/llms.txt Commands to initialize, add, list, use, edit, and remove contexts for managing AsyncAPI configurations. Use contexts to easily switch between different service configurations or file paths. ```bash asyncapi config context init . ``` ```bash asyncapi config context init ~ ``` ```bash asyncapi config context add subscriber subscriber/asyncapi.yaml asyncapi config context add notifier notifier/asyncapi.yaml asyncapi config context add monitor monitor/asyncapi.yaml --set-current ``` ```bash asyncapi config context list ``` ```bash asyncapi config context use notifier ``` ```bash asyncapi config context current ``` ```bash asyncapi validate notifier asyncapi generate models typescript subscriber --output ./models ``` ```bash asyncapi config context edit monitor monitor/v2/asyncapi.yaml ``` ```bash asyncapi config context remove subscriber ``` -------------------------------- ### Deploy Generated Documentation to GitHub Pages Source: https://context7.com/asyncapi/cli/llms.txt This step deploys the generated HTML documentation to GitHub Pages. It requires a GitHub token and specifies the branch and folder for deployment. ```yaml # Publish to GitHub Pages - name: Deploy to GitHub Pages uses: JamesIves/github-pages-deploy-action@3.4.2 with: ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} BRANCH: gh-pages FOLDER: generated-html ``` -------------------------------- ### Integration Test Structure for CLI Commands Source: https://github.com/asyncapi/cli/blob/master/docs/debugging-testing.md Structure for integration tests of CLI commands using Oclif. Includes setup for valid/invalid input, exit codes, and flags, with assertions on stdout/stderr. ```typescript // test/integration/mycommand.test.ts import { expect, test } from '@oclif/test'; import path from 'path'; const validSpec = path.resolve(__dirname, '../fixtures/specification.yml'); const invalidSpec = path.resolve(__dirname, '../fixtures/specification-invalid.yml'); describe('mycommand', () => { describe('with valid input', () => { test .stdout() .command(['mycommand', validSpec]) .it('should succeed with valid specification', (ctx) => { expect(ctx.stdout).to.contain('Success'); }); }); describe('with invalid input', () => { test .stderr() .command(['mycommand', invalidSpec]) .exit(1) .it('should fail with invalid specification', (ctx) => { expect(ctx.stderr).to.contain('Error'); }); }); describe('with flags', () => { test .stdout() .command(['mycommand', validSpec, '--output', 'result.json']) .it('should handle output flag', (ctx) => { expect(ctx.stdout).to.contain('saved'); }); }); }); ``` -------------------------------- ### Clone AsyncAPI CLI Repository Source: https://github.com/asyncapi/cli/blob/master/DEVELOPMENT.md Clone the repository and navigate into the project directory. Ensure your fork is set up correctly with remotes. ```bash git clone https://github.com/{your_username}/cli.git cd cli ``` -------------------------------- ### Generate Files from Template with Parameters Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Use this command to generate files from an AsyncAPI definition using a specified template. You can pass custom parameters to the template and force overwriting existing files. ```bash asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template --param version=1.0.0 singleFile=true --output ./docs --force-write ``` -------------------------------- ### VS Code Debugger Configuration for CLI Commands Source: https://github.com/asyncapi/cli/blob/master/docs/debugging-testing.md Configure VS Code's launch.json to debug CLI commands. This setup allows launching the CLI with specific arguments and environment variables. ```json { "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "Debug CLI Command", "program": "${workspaceFolder}/bin/run", "args": ["validate", "./test/fixtures/specification.yml"], "env": { "NODE_ENV": "development", "TEST": "1" }, "sourceMaps": true, "outFiles": ["${workspaceFolder}/lib/**/*.js"] }, { "type": "node", "request": "launch", "name": "Debug Current Test File", "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", "args": [ "--require", "ts-node/register", "--require", "tsconfig-paths/register", "--timeout", "100000", "${file}" ], "env": { "NODE_ENV": "development", "TEST": "1", "CUSTOM_CONTEXT_FILENAME": "test.asyncapi-cli" }, "sourceMaps": true } ] } ``` -------------------------------- ### Create Changeset File Source: https://github.com/asyncapi/cli/blob/master/DEVELOPMENT.md Manually create a markdown file in the `.changeset` directory to define release types for packages. ```markdown --- "@asyncapi/cli": minor --- Adding new Release Github Flow to the Turborepo. No new features or bugfixes were introduced. ``` -------------------------------- ### Run All Tests with npm Source: https://github.com/asyncapi/cli/blob/master/docs/debugging-testing.md Execute all tests in the project using the standard npm test command. ```bash npm test ``` -------------------------------- ### Download Latest AsyncAPI CLI for Alpine Linux Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Download the latest Alpine-compatible AsyncAPI CLI tar.gz archive for musl-based systems. ```bash curl -OL https://github.com/asyncapi/cli/releases/latest/download/asyncapi-alpine.tar.gz ``` -------------------------------- ### Run a Single Test File Source: https://github.com/asyncapi/cli/blob/master/docs/debugging-testing.md Execute a specific test file by providing its path. ```bash npm run test:one -- test/integration/validate.test.ts ``` -------------------------------- ### Generate Template from AsyncAPI Document Source: https://github.com/asyncapi/cli/blob/master/assets/create-template/templates/default/readme.md Use this command to generate a project template for a specific AsyncAPI document. Replace `` with the name of your template and provide the path to your AsyncAPI document. ```bash asyncapi generate fromTemplate ../asyncapi-template ``` -------------------------------- ### Generate from Template Source: https://context7.com/asyncapi/cli/llms.txt Generate artifacts like documentation or applications from an AsyncAPI document using a specified template. Supports various template sources and custom parameters. ```sh # Generate HTML documentation asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template \ --output ./docs \ --force-write ``` ```sh # Generate Markdown documentation with custom parameters asyncapi generate fromTemplate asyncapi.yaml @asyncapi/markdown-template@2.0.0 \ --param version=1.0.0 singleFile=true \ --output ./docs \ --force-write ``` ```sh # Use a private registry template asyncapi generate fromTemplate asyncapi.yaml my-org/my-template \ --registry-url https://npm.mycompany.com \ --registry-token $NPM_TOKEN \ --output ./generated ``` ```sh # Watch mode – regenerates on spec changes asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template \ --output ./docs \ --watch ``` ```sh # Install template dependencies automatically, disable specific hooks asyncapi generate fromTemplate asyncapi.yaml @asyncapi/nodejs-template \ --install \ --disable-hook generate:after \ --output ./app \ --force-write ``` -------------------------------- ### List Contexts Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Lists all the stored contexts in the store. ```APIDOC ## `asyncapi config context list` ### Description List all the stored contexts in the store. ### Flags - `-h`, `--help`: Show CLI help. ``` -------------------------------- ### Set Up Environment Variables for Debugging Source: https://github.com/asyncapi/cli/blob/master/docs/debugging-testing.md Configure environment variables to enable development mode, disable analytics during testing, and specify custom context files. ```bash # Enable development mode (verbose logging) export NODE_ENV=development # Disable analytics during testing export TEST=1 # Set custom context file for testing export CUSTOM_CONTEXT_FILENAME="test.asyncapi-cli" export CUSTOM_CONTEXT_FILE_LOCATION="" ``` -------------------------------- ### Run Custom AsyncAPI CLI Command Source: https://context7.com/asyncapi/cli/llms.txt This snippet demonstrates how to execute any custom AsyncAPI CLI command, such as bundling an AsyncAPI document. It uses the 'custom' command mode. ```yaml # Run any CLI command using 'custom' mode - name: Bundle AsyncAPI document uses: asyncapi/cli@v2.16.0 with: command: custom custom_command: bundle ./asyncapi.yaml --output final-asyncapi.yaml ``` -------------------------------- ### Generate HTML from AsyncAPI Document with Custom Template Source: https://github.com/asyncapi/cli/blob/master/docs/github-action.md Use this snippet to generate HTML documentation from an AsyncAPI file, specifying a custom template and output directory. The `-p` flag in `parameters` is required for template-specific arguments. ```yaml - name: Generating HTML from my AsyncAPI document uses: asyncapi/cli@v2.16.0 # You can use any version you want with: command: generate filepath: ./docs/api/asyncapi.yaml template: "@asyncapi/html-template@0.9.0" #In case of template from npm. Or can use a link. output: ./generated-html parameters: "-p baseHref=/test-experiment/ sidebarOrganization=byTags" ``` -------------------------------- ### Run All Tests Source: https://github.com/asyncapi/cli/blob/master/docs/contributing-prs.md Execute all tests in the project, including unit and integration tests. ```bash npm run cli:test ``` -------------------------------- ### Run Tests with Coverage Source: https://github.com/asyncapi/cli/blob/master/docs/debugging-testing.md Execute CLI tests and generate a coverage report in the ./coverage/ directory. ```bash npm run cli:test # Coverage report is generated in ./coverage/ ``` -------------------------------- ### Download Latest AsyncAPI CLI for Debian Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Use this command to download the latest AsyncAPI CLI .deb package for Debian-based systems. ```bash curl -OL https://github.com/asyncapi/cli/releases/latest/download/asyncapi.deb ``` -------------------------------- ### AsyncAPI CLI Configuration Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Accesses CLI configuration settings. ```bash asyncapi config ``` -------------------------------- ### Stringified Minimal Empty Context File Source: https://github.com/asyncapi/cli/blob/master/docs/context.md The stringified version of a minimal AsyncAPI context configuration file. This format is useful for embedding or transmitting the configuration as a single string. ```json {"store":{}} ``` -------------------------------- ### asyncapi config auth add PATTERN TOKEN Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Add an authentication configuration for resolving $ref files that require HTTP Authorization. ```APIDOC ## `asyncapi config auth add PATTERN TOKEN` ### Description Add an authentication config for resolving $ref files requiring HTTP Authorization. ### Usage ```bash $ asyncapi config auth add PATTERN TOKEN [-a ] [-h ...] ``` ### Arguments - `PATTERN`: Glob pattern for matching protected URLs (e.g. github.com/org/repo/**/*.*) - `TOKEN`: Authentication token or environment variable reference (prefix with $, e.g. $GITHUB_TOKEN) ### Flags - `-a`, `--auth-type=`: Authentication type (default is "Bearer") - `-h`, `--header=...`: Additional header in key=value format; can be used multiple times. ``` -------------------------------- ### Build Docker Image Source: https://github.com/asyncapi/cli/blob/master/DEVELOPMENT.md Build the Docker image for the CLI. This command is useful for isolated testing environments. ```bash npm run docker:build ``` -------------------------------- ### asyncapi config context Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Manage short aliases for full paths to AsyncAPI documents. ```APIDOC ## `asyncapi config context` ### Description Manage short aliases for full paths to AsyncAPI documents ### Usage ```bash $ asyncapi config context ``` ``` -------------------------------- ### Download Latest AsyncAPI CLI for glibc Linux Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Download the latest AsyncAPI CLI tar.gz archive for glibc-based Linux distributions. ```bash curl -OL https://github.com/asyncapi/cli/releases/latest/download/asyncapi.tar.gz ``` -------------------------------- ### Show Versions Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Displays the versions of AsyncAPI tools currently in use. ```APIDOC ## `asyncapi config versions` ### Description Show versions of AsyncAPI tools used. ### Flags - `-h`, `--help`: Show CLI help. ``` -------------------------------- ### Show AsyncAPI Tool Versions Source: https://context7.com/asyncapi/cli/llms.txt Displays the versions of all AsyncAPI tool libraries bundled within the CLI. Useful for checking compatibility and debugging. ```bash asyncapi config versions ``` -------------------------------- ### AsyncAPI Context Management Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Manages short aliases for full paths to AsyncAPI documents. ```bash asyncapi config context ``` -------------------------------- ### Use Context Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Sets a specified context as the current one. ```APIDOC ## `asyncapi config context use CONTEXT-NAME` ### Description Set a context as current. ### Arguments - `CONTEXT-NAME` (string): name of the saved context. ### Flags - `-h`, `--help`: Show CLI help. ``` -------------------------------- ### Rebuild Project for Path Aliases Source: https://github.com/asyncapi/cli/blob/master/DEVELOPMENT.md Run this command to rebuild the project, which can resolve path alias issues. ```bash npm run build ``` -------------------------------- ### Bundle AsyncAPI Documents Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Bundles one or multiple AsyncAPI documents and their references. Use the `--output` flag to specify an output file, otherwise, the result is printed to the console. The `--base` flag is required when overwriting properties, and `--baseDir` resolves paths to bundled documents. ```bash asyncapi bundle ./asyncapi.yaml > final-asyncapi.yaml ``` ```bash asyncapi bundle ./asyncapi.yaml --output final-asyncapi.yaml ``` ```bash asyncapi bundle ./asyncapi.yaml ./features.yaml ``` ```bash asyncapi bundle ./asyncapi.yaml ./features.yaml --base ./main.yaml ``` ```bash asyncapi bundle ./asyncapi.yaml ./features.yaml --base ./main.yaml --xOrigin ``` ```bash asyncapi bundle ./asyncapi.yaml -o final-asyncapi.yaml --base ../public-api/main.yaml --baseDir ./social-media/comments-service ``` -------------------------------- ### asyncapi config Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Manage CLI configuration settings, including analytics and authentication. ```APIDOC ## `asyncapi config` ### Description CLI config settings ### Usage ```bash $ asyncapi config ``` ``` -------------------------------- ### Build Docker Image for AsyncAPI CLI Action Source: https://github.com/asyncapi/cli/blob/master/docs/github-action.md Command to build the Docker image for the AsyncAPI CLI GitHub Action locally. This is a prerequisite for running the action in a Docker container. ```bash npm run action:docker:build ``` -------------------------------- ### Bundle Multi-File AsyncAPI Documents Source: https://context7.com/asyncapi/cli/llms.txt Resolves all $ref pointers across multiple AsyncAPI files into a single bundled output file. Optionally adds x-origin properties to trace original $ref values and uses --baseDir for relative reference resolution. ```sh # Bundle a single file (output to stdout) asyncapi bundle ./asyncapi.yaml > final-asyncapi.yaml ``` ```sh # Bundle to a specific output file asyncapi bundle ./asyncapi.yaml --output final-asyncapi.yaml ``` ```sh # Bundle multiple files asyncapi bundle ./asyncapi.yaml ./features.yaml --output bundled.yaml ``` ```sh # Bundle with a base file to merge top-level properties asyncapi bundle ./asyncapi.yaml ./features.yaml \ --base ./main.yaml \ --output bundled.yaml ``` ```sh # Bundle with x-origin tracking and a baseDir for relative ref resolution asyncapi bundle ./asyncapi.yaml \ --base ../public-api/main.yaml \ --baseDir ./social-media/comments-service \ --output final-asyncapi.yaml \ --xOrigin ``` -------------------------------- ### AsyncAPI CLI GitHub Action - Custom Command Usage Source: https://github.com/asyncapi/cli/blob/master/docs/github-action.md Use this snippet to run a custom AsyncAPI CLI command, such as bundling a document. Ensure the entire command and its parameters are passed as a single string to the `custom_command` input. ```yaml - name: Generating HTML from my AsyncAPI document uses: asyncapi/cli@v2.16.0# You can use any version you want with: custom_command: bundle ./asyncapi.yaml --output final-asyncapi.yaml ``` -------------------------------- ### Add Authentication Configuration Source: https://github.com/asyncapi/cli/blob/master/docs/usage.md Adds an authentication configuration for resolving $ref files that require HTTP Authorization. Specify a glob pattern for matching URLs and a token (or environment variable reference). Additional headers can be provided using the `--header` flag. ```bash asyncapi config auth add PATTERN TOKEN [-a ] [-h ...] ``` -------------------------------- ### Configure HTTP Authentication for Private $ref Resolution Source: https://context7.com/asyncapi/cli/llms.txt Add authentication credentials for resolving private HTTP resources. Supports Bearer tokens, environment variables, and custom authentication types with additional headers. ```bash asyncapi config auth add "github.com/myorg/**/*.*" $GITHUB_TOKEN ``` ```bash asyncapi config auth add "schema-registry.internal/**" $SCHEMA_TOKEN ``` ```bash asyncapi config auth add "api.example.com/schemas/**/*" $API_KEY \ --auth-type ApiKey \ --header "X-Tenant-ID=my-tenant" \ --header "X-Version=v2" ``` -------------------------------- ### Download Specific AsyncAPI CLI Version for Debian Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Replace `` with the desired version to download a specific .deb package. ```bash curl -OL https://github.com/asyncapi/cli/releases/download//asyncapi.deb ``` -------------------------------- ### Untar Alpine AsyncAPI CLI Archive Source: https://github.com/asyncapi/cli/blob/master/docs/installation.md Extract the contents of the downloaded Alpine-compatible AsyncAPI CLI tar.gz archive. ```bash tar -xzf asyncapi-alpine.tar.gz ``` -------------------------------- ### Generate HTML Documentation Source: https://context7.com/asyncapi/cli/llms.txt This snippet generates HTML documentation from an AsyncAPI specification. It specifies the output directory and custom parameters for the HTML template. ```yaml # Generate HTML docs from AsyncAPI spec - name: Generate HTML documentation uses: asyncapi/cli@v2.16.0 with: command: generate filepath: docs/api/asyncapi.yaml template: "@asyncapi/html-template@0.9.0" output: generated-html parameters: "-p baseHref=/my-api/ sidebarOrganization=byTags" ```