Gathering detailed insights and metrics for @apidevtools/swagger-cli
Gathering detailed insights and metrics for @apidevtools/swagger-cli
Gathering detailed insights and metrics for @apidevtools/swagger-cli
Gathering detailed insights and metrics for @apidevtools/swagger-cli
Swagger 2.0 and OpenAPI 3.0 command-line tool
npm install @apidevtools/swagger-cli
Typescript
Module System
Min. Node Version
Node Version
NPM Version
94.1
Supply Chain
99.5
Quality
76.5
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
40,070,883
Last Day
5,257
Last Week
220,182
Last Month
1,045,405
Last Year
12,648,300
MIT License
517 Stars
200 Commits
70 Forks
13 Watchers
2 Branches
8 Contributors
Updated on May 22, 2025
Minified
Minified + Gzipped
Latest Version
4.0.4
Package Id
@apidevtools/swagger-cli@4.0.4
Size
6.96 kB
NPM Version
6.14.4
Node Version
10.21.0
Published on
Jul 19, 2020
Cumulative downloads
Total Downloads
Last Day
1%
5,257
Compared to previous day
Last Week
-22.4%
220,182
Compared to previous week
Last Month
-10.5%
1,045,405
Compared to previous month
Last Year
5.8%
12,648,300
Compared to previous year
$ref
pointersInstall using npm:
1npm install -g @apidevtools/swagger-cli
swagger-cli <command> [options] <file>
Commands:
validate Validates an API definition in Swagger 2.0 or OpenAPI 3.0 format
bundle Bundles a multi-file API definition into a single file
Options:
-h, --help Show help for any command
-v, --version Output the CLI version number
-d, --debug [filter] Show debug output, optionally filtered (e.g. "*", "swagger:*", etc.)
The swagger-cli validate
command will validate your Swagger/OpenAPI definition against the Swagger 2.0 schema or OpenAPI 3.0 Schema. It also performs additional validations against the specification, which will catch some things that aren't covered by the schema, such as duplicate parameters, invalid MIME types, etc.
The command will exit with a non-zero code if the API is invalid.
swagger-cli validate [options] <file>
Options:
--no-schema Do NOT validate against the Swagger/OpenAPI JSON schema
--no-spec Do NOT validate against the Swagger/OpenAPI specification
There is a useful Python tool called pre-commit that can be used to execute a wide suite of pre-commit checks. The swagger-cli validate
command can be integrated as part of a git pre-commit hook by adding the following configuration to the repos
entry of an existing .pre-commit-config.yaml
file.
- repo: https://github.com/APIDevTools/swagger-cli
rev: v2.2.1
hooks:
- id: swagger-validation
args: ["validate", "<path to root swagger>"]
The intention is to point to single root swagger that references multiple swagger definitions. The above hook will execute the swagger-cli validation
against the root swagger anytime that a file matching the pattern .*swagger.*\.(json|yaml|yml)
is modified. Any failures in this validation will prevent the git commit from being processed.
The Swagger and OpenAPI specs allows you to split your API definition across multiple files using $ref
pointers to reference each file. You can use the swagger-cli bundle
command to combine all of those referenced files into a single file, which is useful for distribution or interoperation with other tools.
By default, the swagger-cli bundle
command tries to keep the output file size as small as possible, by only embedding each referenced file once. If the same file is referenced multiple times, then any subsequent references are simply modified to point to the single inlined copy of the file. If you want to produce a bundled file without any $ref
pointers, then add the --dereference
option. This will result in a larger file size, since multiple references to the same file will result in that file being embedded multiple times.
If you don't specify the --outfile
option, then the bundled API will be written to stdout, which means you can pipe it to other commands.
The result of this method by default is written as JSON. It can be changed to YAML with the --type
option, by passing the yaml
value.
swagger-cli bundle [options] <file>
Options:
-o, --outfile <file> The output file
-r, --dereference Fully dereference all $ref pointers
-f, --format <spaces> Formats the output using the given number of spaces
(the default is 2 spaces)
-t, --type <filetype> Defines the output file type. The valid values are: json, yaml
(the default is JSON)
-w, --wrap <column> Set the line length for YAML strings
(the default is no wrapping)
I welcome any contributions, enhancements, and bug-fixes. Open an issue on GitHub and submit a pull request.
To build/test the project locally on your computer:
Clone this repo
git clone https://github.com/APIDevTools/swagger-cli.git
Install dependencies
npm install
Run the tests
npm test
Swagger CLI is 100% free and open-source, under the MIT license. Use it however you want.
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
Thanks to these awesome companies for their support of Open Source developers ❤
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
project is archived
Details
Reason
Found 2/28 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
33 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More