@@ -7,7 +7,7 @@ customization through CLI options and passthrough arguments.
77
88** Supports:** OpenAPI, AsyncAPI, Arazzo
99
10- ** Wraps:** [ Redocly] ( https://github.com/Redocly/redocly-cli ) | [ Spectral] ( https://github.com/stoplightio/spectral )
10+ ** Wraps:** [ AsyncAPI ] ( https://www.asyncapi.com/en/tools/cli ) | [ Redocly] ( https://github.com/Redocly/redocly-cli ) | [ Spectral] ( https://github.com/stoplightio/spectral )
1111
1212[ ![ CI] ( https://github.com/bymbly/api-tools/actions/workflows/workflow.yaml/badge.svg )] ( https://github.com/bymbly/api-tools/actions/workflows/workflow.yaml )
1313[ ![ NPM Version] ( https://img.shields.io/npm/v/@bymbly/api-tools )] ( https://www.npmjs.com/package/@bymbly/api-tools )
@@ -32,6 +32,13 @@ customization through CLI options and passthrough arguments.
3232 - [ Command Structure] ( #command-structure )
3333 - [ Global Options] ( #global-options )
3434 - [ Commands] ( #commands )
35+ - [ AsyncAPI Commands] ( #asyncapi-commands )
36+ - [ ` asyncapi lint ` ] ( #asyncapi-lint )
37+ - [ ` asyncapi bundle ` ] ( #asyncapi-bundle )
38+ - [ ` asyncapi format ` ] ( #asyncapi-format )
39+ - [ ` asyncapi generate from-template ` ] ( #asyncapi-generate-from-template )
40+ - [ ` asyncapi generate docs ` ] ( #asyncapi-generate-docs )
41+ - [ ` asyncapi build-docs ` ] ( #asyncapi-build-docs )
3542 - [ Spectral Commands] ( #spectral-commands )
3643 - [ ` spectral lint ` ] ( #spectral-lint )
3744 - [ ` spectral init ` ] ( #spectral-init )
@@ -76,12 +83,15 @@ Add scripts to your `package.json`:
7683``` json
7784{
7885 "scripts" : {
79- "lint" : " npm run lint:spectral && npm run lint:redocly" ,
86+ "lint" : " npm run lint:spectral && npm run lint:redocly && npm run lint:asyncapi " ,
8087 "lint:spectral" : " api-tools spectral lint" ,
8188 "lint:redocly" : " api-tools redocly lint" ,
82- "bundle" : " api-tools redocly bundle" ,
89+ "lint:asyncapi" : " api-tools asyncapi lint" ,
90+ "bundle:openapi" : " api-tools redocly bundle" ,
91+ "bundle:asyncapi" : " api-tools asyncapi bundle" ,
8392 "join" : " api-tools redocly join" ,
84- "docs" : " api-tools redocly build-docs" ,
93+ "docs:openapi" : " api-tools redocly build-docs" ,
94+ "docs:asyncapi" : " api-tools asyncapi build-docs" ,
8595 "arazzo:gen" : " api-tools redocly generate-arazzo" ,
8696 "test:api" : " api-tools redocly respect"
8797 }
@@ -91,12 +101,14 @@ Add scripts to your `package.json`:
91101Run:
92102
93103``` bash
94- npm run lint # Lint with both Spectral and Redocly
95- npm run bundle # Bundle OpenAPI documents
96- npm run join # Join OpenAPI documents
97- npm run docs # Generate HTML documentation
98- npm run arazzo:gen # Generate Arazzo workflow starter
99- npm run test:api # Execute Arazzo workflow tests
104+ npm run lint # Lint with both Spectral and Redocly
105+ npm run bundle:openapi # Bundle OpenAPI documents
106+ npm run bundle:asyncapi # Bundle AsyncAPI documents
107+ npm run join # Join OpenAPI documents
108+ npm run docs:openapi # Generate OpenAPI HTML documentation
109+ npm run docs:asyncapi # Generate AsyncAPI HTML documentation
110+ npm run arazzo:gen # Generate Arazzo workflow starter
111+ npm run test:api # Execute Arazzo workflow tests
100112```
101113
102114## Command Structure
@@ -115,6 +127,184 @@ Available for all commands:
115127
116128## Commands
117129
130+ ### AsyncAPI Commands
131+
132+ #### ` asyncapi lint `
133+
134+ Validate and lint AsyncAPI documents.
135+
136+ ** Usage:**
137+
138+ ``` bash
139+ api-tools asyncapi lint [input] [options]
140+ ```
141+
142+ ** Options:**
143+
144+ - ` [input] ` - Document path (default: ` asyncapi/asyncapi.yaml ` )
145+ - ` --format <format> ` - Output format (default: ` stylish ` )
146+ - Choices: ` json ` , ` stylish ` , ` junit ` , ` html ` , ` teamcity ` , ` pretty ` , ` github-actions ` , ` sarif ` ,
147+ ` code-climate ` , ` gitlab ` , ` markdown `
148+ - ` --output <file> ` - Write output to file
149+ - ` --fail-severity <level> ` - Fail threshold (default: ` warn ` )
150+ - Choices: ` error ` , ` warn ` , ` info ` , ` hint `
151+
152+ ** Examples:**
153+
154+ ``` bash
155+ # Lint default AsyncAPI spec
156+ api-tools asyncapi lint
157+
158+ # Lint specific file
159+ api-tools asyncapi lint custom/spec.yaml
160+
161+ # JSON output
162+ api-tools asyncapi lint --format json --output results.json
163+
164+ # Only fail on errors
165+ api-tools asyncapi lint --fail-severity error
166+ ```
167+
168+ #### ` asyncapi bundle `
169+
170+ Bundle AsyncAPI documents into a single file.
171+
172+ ** Usage:**
173+
174+ ``` bash
175+ api-tools asyncapi bundle [input] [options]
176+ ```
177+
178+ ** Options:**
179+
180+ - ` [input] ` - Document path (default: ` asyncapi/asyncapi.yaml ` )
181+ - ` --output <path> ` - Output file path (default: ` dist/bundle/asyncapi.yaml ` )
182+ - ` --ext <extension> ` - Output extension (overrides ` --output ` extension)
183+ - Choices: ` json ` , ` yaml ` , ` yml `
184+ - ` --x-origin ` - Generate x-origin fields with dereferenced $ref history
185+
186+ ** Examples:**
187+
188+ ``` bash
189+ # Bundle with defaults
190+ api-tools asyncapi bundle
191+
192+ # Bundle to JSON
193+ api-tools asyncapi bundle --ext json
194+
195+ # Bundle with x-origin tracking
196+ api-tools asyncapi bundle --x-origin
197+
198+ # Custom output
199+ api-tools asyncapi bundle --output dist/api-bundle.yaml
200+ ```
201+
202+ #### ` asyncapi format `
203+
204+ Convert AsyncAPI documents between formats (YAML <---> JSON).
205+
206+ ** Usage:**
207+
208+ ``` bash
209+ api-tools asyncapi format [input] [options]
210+ ```
211+
212+ ** Options:**
213+
214+ - ` [input] ` - Document path (default: ` asyncapi/asyncapi.yaml ` )
215+ - ` --output <file> ` - Output file path (default: ` dist/format/asyncapi.json ` )
216+ - ` --ext <extension> ` - Output extension (overrides ` --output ` extension)
217+ - Choices: ` json ` , ` yaml ` , ` yml `
218+
219+ ** Examples:**
220+
221+ ``` bash
222+ # Convert to JSON (default)
223+ api-tools asyncapi format
224+
225+ # Convert to YAML
226+ api-tools asyncapi format --ext yaml
227+
228+ # Custom input and output
229+ api-tools asyncapi format input.json --output output.yaml
230+ ```
231+
232+ #### ` asyncapi generate from-template `
233+
234+ Generate code or documentation from AsyncAPI documents using templates.
235+
236+ ** Usage:**
237+
238+ ``` bash
239+ api-tools asyncapi generate from-template < template> [input] [options]
240+ ```
241+
242+ ** Options:**
243+
244+ - ` <template> ` - ** REQUIRED.** Template name or URL (e.g., ` @asyncapi/html-template ` )
245+ - ` [input] ` - Document path (default: ` asyncapi/asyncapi.yaml ` )
246+ - ` --output <directory> ` - Output directory (default: ` dist/generated/ ` )
247+ - ` --params <key=value...> ` - Template parameters (can be repeated)
248+ - ` --force-write ` - Overwrite existing files
249+
250+ ** Examples:**
251+
252+ ``` bash
253+ # Generate HTML docs
254+ api-tools asyncapi generate from-template @asyncapi/html-template
255+
256+ # Generate with custom output
257+ api-tools asyncapi generate from-template @asyncapi/nodejs-template \
258+ --output src/generated
259+
260+ # Generate with parameters
261+ api-tools asyncapi generate from-template @asyncapi/html-template \
262+ --params singleFile=true \
263+ --params version=1.0.0
264+ ```
265+
266+ #### ` asyncapi generate docs `
267+
268+ Generate HTML documentation (convenience wrapper around ` from-template ` with HTML template).
269+
270+ ** Usage:**
271+
272+ ``` bash
273+ api-tools asyncapi generate docs [input] [options]
274+ ```
275+
276+ ** Options:**
277+
278+ - ` [input] ` - Document path (default: ` asyncapi/asyncapi.yaml ` )
279+ - ` --output <file> ` - Output HTML file (default: ` dist/docs/asyncapi.html ` )
280+ - ` --params <key=value...> ` - Template parameters (can be repeated)
281+ - ` --single-file ` - Generate single HTML file (default: ` true ` )
282+ - ` --no-single-file ` - Generate multiple files
283+
284+ ** Examples:**
285+
286+ ``` bash
287+ # Generate single-file docs
288+ api-tools asyncapi generate docs
289+
290+ # Generate multi-file docs
291+ api-tools asyncapi generate docs --no-single-file
292+
293+ # Custom output and parameters
294+ api-tools asyncapi generate docs --output public/api.html \
295+ --params version=2.0.0
296+ ```
297+
298+ #### ` asyncapi build-docs `
299+
300+ Alias for ` asyncapi generate docs ` - builds HTML documentation from AsyncAPI documents.
301+
302+ ``` bash
303+ api-tools asyncapi build-docs [input] [options]
304+ ```
305+
306+ See ` asyncapi generate docs ` for full usage details.
307+
118308### Spectral Commands
119309
120310#### ` spectral lint `
@@ -321,7 +511,8 @@ api-tools redocly join <inputs...> [options]
321511api-tools redocly join api-1.yaml api-2.yaml
322512
323513# Join with custom output
324- api-tools redocly join users-api.yaml orders-api.yaml --output dist/combined-api.yaml
514+ api-tools redocly join users-api.yaml orders-api.yaml \
515+ --output dist/combined-api.yaml
325516
326517# Resolve component naming conflicts using version
327518api-tools redocly join museum-v1.yaml museum-v2.yaml \
@@ -435,11 +626,16 @@ project/
435626│ └── auto-generated.arazzo.yaml # Generated starter
436627└── dist/
437628 ├── bundle/
438- │ └── openapi.yaml # Bundled output
629+ │ ├── openapi.yaml # OpenAPI bundled output
630+ │ └── asyncapi.yaml # AsyncAPI bundled output
631+ ├── format/
632+ │ └── asyncapi.json # AsyncAPI format output
633+ ├── generated/ # AsyncAPI template output
439634 ├── join/
440635 │ └── openapi.yaml # Joined output
441636 └── docs/
442- └── openapi.html # Generated docs
637+ ├── openapi.html # OpenAPI docs
638+ └── asyncapi.html # AsyncAPI docs (or asyncapi/ for multi-file)
443639```
444640
445641## Configuration Files
@@ -551,16 +747,21 @@ api-tools spectral lint --openapi
551747# Lint using Redocly during development
552748api-tools redocly lint --openapi
553749
750+ # Lint AsyncAPI during development
751+ api-tools asyncapi lint
752+
554753# Generate docs for local preview
555754api-tools redocly build-docs
755+ api-tools asyncapi build-docs
556756```
557757
558758### Pre-commit
559759
560760``` bash
561761# Fast validation
562- api-tools spectral lint --fail-severity error
762+ api-tools spectral lint
563763api-tools redocly lint
764+ api-tools asyncapi lint
564765```
565766
566767### CI Pipeline
@@ -569,8 +770,11 @@ api-tools redocly lint
569770# Full validation with outputs
570771api-tools spectral lint --format github-actions
571772api-tools redocly lint --format github-actions
773+ api-tools asyncapi lint --format github-actions
572774api-tools redocly bundle --output dist/openapi.yaml
775+ api-tools asyncapi bundle --output dist/asyncapi.yaml
573776api-tools redocly build-docs --output dist/api-docs.html
777+ api-tools asyncapi build-docs --output dist/asyncapi-docs.html
574778```
575779
576780### API Testing
0 commit comments