Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
swaggerhub-cli
Advanced tools
The SwaggerHub CLI enables teams to build automation and workflows around SwaggerHub. Teams can use it in places like their CI/CD pipeline to create new APIs, create and update API versions, and mark API versions as published and default among other features. Every team has their own workflow, and the SwaggerHub CLI can help teams build the workflow that fits their needs.
Node.js 12 or later.
$ npm i -g swaggerhub-cli
The SwaggerHub CLI can be configured through environment variables or through the swaggerhub configure
command. The CLI will look for the following environment variables.
SWAGGERHUB_API_KEY
(required) – Important: keep this key secure. This is the SwaggerHub API key the CLI will use for authentication. You can find your API key on the user settings page in SwaggerHub.SWAGGERHUB_URL
(optional, default is https://api.swaggerhub.com
) – Customers with on-premise installations need to point this to their on-premise API, which is http(s)://{swaggerhub-host}/v1
(do not append a backslash).Alernatively, you can use the swaggerhub configure
command to create a configuration file for the CLI to use. This command will walk you through the steps to set up the necessary configurations.
$ swaggerhub configure
? SwaggerHub URL: https://api.swaggerhub.com
? API Key: <your-api-key>
Environment variables take precedence over the configuration file created by this command.
If your SwaggerHub On-Premise instance uses a self-signed or privately signed SSL certificate, there are additional steps required to make the SwaggerHub CLI trust this certificate.
By default, Node.js rejects self-signed or privately signed SSL certificates because their root CA is not known. You will see an error like this in the CLI output:
FetchError: request to https://... failed, reason: self signed certificate
The solution is to use the NODE_EXTRA_CA_CERTS
environment variable to specify custom trusted certificates for Node.js.
Start by creating a .pem file containing your custom trusted certificates in the PEM format.
-----BEGIN CERTIFICATE-----
CA root certificate
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
Intermediate certificate 1
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
Intermediate certificate 2
-----END CERTIFICATE-----
Specify the path to this PEM file in the NODE_EXTRA_CA_CERTS
environment variable.
macOS/*nix/bash examples:
export NODE_EXTRA_CA_CERTS=~/Work/extra-ca-certs.pem # '~' means the home folder of the logged-in user
export NODE_EXTRA_CA_CERTS=$HOME/.ssh/extra-ca-certs.pem
export NODE_EXTRA_CA_CERTS=/Users/username/Work/extra-ca-certs.pem
Windows examples:
:: Both forward and backslashes are OK
set NODE_EXTRA_CA_CERTS=C:\Work\extra-ca-certs.pem
set NODE_EXTRA_CA_CERTS=C:/Work/extra-ca-certs.pem
:: You can also define the path itself using environment variables
set NODE_EXTRA_CA_CERTS=%USERPROFILE%\extra-ca-certs.pem
$ swaggerhub COMMAND
running command...
$ swaggerhub (-v|--version|version)
swaggerhub/0.1.2 darwin-x64 node-v12.13.0
$ swaggerhub --help [COMMAND]
USAGE
$ swaggerhub COMMAND
...
swaggerhub api:create OWNER/API_NAME/[VERSION]
swaggerhub api:delete OWNER/API_NAME/[VERSION]
swaggerhub api:get OWNER/API_NAME/[VERSION]
swaggerhub api:publish OWNER/API_NAME/VERSION
swaggerhub api:setdefault OWNER/API_NAME/VERSION
swaggerhub api:unpublish OWNER/API_NAME/VERSION
swaggerhub api:update OWNER/API_NAME/[VERSION]
swaggerhub api:validate OWNER/API_NAME/[VERSION]
swaggerhub configure
swaggerhub domain:create OWNER/DOMAIN_NAME/[VERSION]
swaggerhub domain:delete OWNER/DOMAIN_NAME/[VERSION]
swaggerhub domain:get OWNER/DOMAIN_NAME/[VERSION]
swaggerhub domain:publish OWNER/DOMAIN_NAME/VERSION
swaggerhub domain:setdefault OWNER/DOMAIN_NAME/VERSION
swaggerhub domain:unpublish OWNER/DOMAIN_NAME/VERSION
swaggerhub domain:update OWNER/DOMAIN_NAME/[VERSION]
swaggerhub help [COMMAND]
swaggerhub integration:create OWNER/API_NAME/[VERSION]
swaggerhub integration:delete OWNER/API_NAME/VERSION/INTEGRATION_ID
swaggerhub integration:execute OWNER/API_NAME/VERSION/INTEGRATION_ID
swaggerhub integration:get OWNER/API_NAME/VERSION/INTEGRATION_ID
swaggerhub integration:list OWNER/API_NAME/[VERSION]
swaggerhub integration:update OWNER/API_NAME/VERSION/INTEGRATION_ID
swaggerhub plugins
swaggerhub plugins:inspect PLUGIN...
swaggerhub plugins:install PLUGIN...
swaggerhub plugins:link PLUGIN
swaggerhub plugins:uninstall PLUGIN...
swaggerhub plugins:update
swaggerhub api:create
creates a new API / API version from a YAML/JSON file
USAGE
$ swaggerhub api:create OWNER/API_NAME/[VERSION]
ARGUMENTS
OWNER/API_NAME/[VERSION] API to create in SwaggerHub
OPTIONS
-f, --file=file (required) file location of API to create
-h, --help show CLI help
--published=publish|unpublish [default: unpublish] sets the lifecycle setting of the API version
--setdefault sets API version to be the default
--visibility=public|private [default: private] visibility of API in SwaggerHub
DESCRIPTION
The API version from the file will be used unless the version is specified in the command argument.
An error will occur if the API version already exists.
EXAMPLES
swaggerhub api:create organization/api/1.0.0 --file api.yaml --visibility public
swaggerhub api:create organization/api --file api.yaml
swaggerhub api:create organization/api/1.0.0 --published=publish --file api.json
swaggerhub api:create organization/api/1.0.0 --setdefault --file api.json
swaggerhub api:create organization/api/1.0.0 --published=publish --setdefault --file api.json
See code: src/commands/api/create.js
swaggerhub api:delete
delete an API or API version
USAGE
$ swaggerhub api:delete OWNER/API_NAME/[VERSION]
ARGUMENTS
OWNER/API_NAME/[VERSION] API to delete in SwaggerHub
OPTIONS
-f, --force delete API without prompting for confirmation
-h, --help show CLI help
EXAMPLES
swaggerhub api:delete organization/api/1.0.0
swaggerhub api:delete organization/api
swaggerhub api:delete organization/api --force
See code: src/commands/api/delete.js
swaggerhub api:get
fetches an API definition
USAGE
$ swaggerhub api:get OWNER/API_NAME/[VERSION]
ARGUMENTS
OWNER/API_NAME/[VERSION] SwaggerHub API to fetch
OPTIONS
-h, --help show CLI help
-j, --json returns the API in JSON format.
-r, --resolved gets the resolved API definition (supported in v1.25+).
DESCRIPTION
When VERSION is not included in the argument, the default version will be returned.
Returns the API in YAML format by default.
EXAMPLES
swaggerhub api:get organization/api
swaggerhub api:get organization/api/1.0.0 --json
See code: src/commands/api/get.js
swaggerhub api:publish
publish an API version
USAGE
$ swaggerhub api:publish OWNER/API_NAME/VERSION
ARGUMENTS
OWNER/API_NAME/VERSION API identifier
OPTIONS
-h, --help show CLI help
EXAMPLE
swaggerhub api:publish organization/api/1.0.0
See code: src/commands/api/publish.js
swaggerhub api:setdefault
set the default version of an API
USAGE
$ swaggerhub api:setdefault OWNER/API_NAME/VERSION
ARGUMENTS
OWNER/API_NAME/VERSION API identifier
OPTIONS
-h, --help show CLI help
EXAMPLE
swaggerhub api:setdefault organization/api/2.0.0
See code: src/commands/api/setdefault.js
swaggerhub api:unpublish
unpublish an API version
USAGE
$ swaggerhub api:unpublish OWNER/API_NAME/VERSION
ARGUMENTS
OWNER/API_NAME/VERSION API identifier
OPTIONS
-h, --help show CLI help
EXAMPLE
swaggerhub api:unpublish organization/api/1.0.0
See code: src/commands/api/unpublish.js
swaggerhub api:update
update an API
USAGE
$ swaggerhub api:update OWNER/API_NAME/[VERSION]
ARGUMENTS
OWNER/API_NAME/[VERSION] API to update in SwaggerHub
OPTIONS
-f, --file=file file location of API to update
-h, --help show CLI help
--published=publish|unpublish sets the lifecycle setting of the API version
--setdefault sets API version to be the default
--visibility=public|private visibility of API in SwaggerHub
DESCRIPTION
The API version from the file will be used unless the version is specified in the command argument.
When no file is specified then the default API version will be updated.
The API visibility can be changed by using visibility flag.
EXAMPLES
swaggerhub api:update organization/api --file api.yaml
swaggerhub api:update organization/api/1.0.0 --file api.json
swaggerhub api:update organization/api/1.0.0 --published=publish --file api.json
swaggerhub api:update organization/api/1.0.0 --setdefault --file api.json
swaggerhub api:update organization/api/1.0.0 --published=unpublish --setdefault --file api.json
swaggerhub api:update organization/api/1.0.0 --visibility=private
See code: src/commands/api/update.js
swaggerhub api:validate
get validation result for an API version
USAGE
$ swaggerhub api:validate OWNER/API_NAME/[VERSION]
ARGUMENTS
OWNER/API_NAME/[VERSION] API Identifier
OPTIONS
-h, --help show CLI help
DESCRIPTION
When VERSION is not included in the argument, the default version will be validated.
An error will occur if the API version does not exist.
EXAMPLES
swaggerhub api:validate organization/api/1.0.0
swaggerhub api:validate organization/api
See code: src/commands/api/validate.js
swaggerhub configure
configure application settings
USAGE
$ swaggerhub configure
OPTIONS
-h, --help show CLI help
DESCRIPTION
Enter the SwaggerHub URL - default is https://api.swaggerhub.com
Customers with on-premise installations need to point this to their on-premise API, which is
http(s)://{swaggerhub-host}/v1
Enter the API Key - this can be retrieved from https://app.swaggerhub.com/settings/apiKey
You can set these as environment variables: SWAGGERHUB_URL, SWAGGERHUB_API_KEY. These take priority over config
settings.
See code: src/commands/configure.js
swaggerhub domain:create
creates a new domain / domain version from a YAML/JSON file
USAGE
$ swaggerhub domain:create OWNER/DOMAIN_NAME/[VERSION]
ARGUMENTS
OWNER/DOMAIN_NAME/[VERSION] Domain to create in SwaggerHub
OPTIONS
-f, --file=file (required) file location of domain to create
-h, --help show CLI help
--published=publish|unpublish [default: unpublish] sets the lifecycle setting of the domain version
--setdefault sets domain version to be the default
--visibility=public|private [default: private] visibility of domain in SwaggerHub
DESCRIPTION
The domain version from the file will be used unless the version is specified in the command argument.
An error will occur if the domain version already exists.
EXAMPLES
swaggerhub domain:create organization/domain/1.0.0 --file domain.yaml --visibility public
swaggerhub domain:create organization/domain --file domain.yaml
swaggerhub domain:create organization/domain/1.0.0 --publish --file domain.json
swaggerhub domain:create organization/domain/1.0.0 --setdefault --file domain.json
swaggerhub domain:create organization/domain/1.0.0 --publish --setdefault --file domain.json
See code: src/commands/domain/create.js
swaggerhub domain:delete
delete a domain or domain version
USAGE
$ swaggerhub domain:delete OWNER/DOMAIN_NAME/[VERSION]
ARGUMENTS
OWNER/DOMAIN_NAME/[VERSION] Domain to delete in SwaggerHub
OPTIONS
-f, --force delete domain without prompting for confirmation
-h, --help show CLI help
EXAMPLES
swaggerhub domain:delete organization/domain/1.0.0
swaggerhub domain:delete organization/domain
swaggerhub domain:delete organization/domain --force
See code: src/commands/domain/delete.js
swaggerhub domain:get
fetches a domain definition
USAGE
$ swaggerhub domain:get OWNER/DOMAIN_NAME/[VERSION]
ARGUMENTS
OWNER/DOMAIN_NAME/[VERSION] SwaggerHub domain to fetch
OPTIONS
-h, --help show CLI help
-j, --json returns the domain in JSON format.
DESCRIPTION
When VERSION is not included in the argument, the default version will be returned.
Returns the domain in YAML format by default.
EXAMPLES
swaggerhub domain:get organization/domain
swaggerhub domain:get organization/domain/1.0.0 --json
See code: src/commands/domain/get.js
swaggerhub domain:publish
publish a domain version
USAGE
$ swaggerhub domain:publish OWNER/DOMAIN_NAME/VERSION
ARGUMENTS
OWNER/DOMAIN_NAME/VERSION Domain identifier
OPTIONS
-h, --help show CLI help
EXAMPLE
swaggerhub domain:publish organization/domain/1.0.0
See code: src/commands/domain/publish.js
swaggerhub domain:setdefault
set the default version of a domain
USAGE
$ swaggerhub domain:setdefault OWNER/DOMAIN_NAME/VERSION
ARGUMENTS
OWNER/DOMAIN_NAME/VERSION domain identifier
OPTIONS
-h, --help show CLI help
EXAMPLE
swaggerhub domain:setdefault organization/domain/2.0.0
See code: src/commands/domain/setdefault.js
swaggerhub domain:unpublish
unpublish a domain version
USAGE
$ swaggerhub domain:unpublish OWNER/DOMAIN_NAME/VERSION
ARGUMENTS
OWNER/DOMAIN_NAME/VERSION Domain identifier
OPTIONS
-h, --help show CLI help
EXAMPLE
swaggerhub domain:unpublish organization/domain/1.0.0
See code: src/commands/domain/unpublish.js
swaggerhub domain:update
update a domain
USAGE
$ swaggerhub domain:update OWNER/DOMAIN_NAME/[VERSION]
ARGUMENTS
OWNER/DOMAIN_NAME/[VERSION] domain to update in SwaggerHub
OPTIONS
-f, --file=file file location of domain to update
-h, --help show CLI help
--published=publish|unpublish sets the lifecycle setting of the domain version
--setdefault sets domain version to be the default
--visibility=public|private visibility of domain in SwaggerHub
DESCRIPTION
The domain version from the file will be used unless the version is specified in the command argument.
When no file is specified then the default domain version will be updated.
The domain visibility can be changed by using visibility flag.
EXAMPLES
swaggerhub domain:update organization/domain --file domain.yaml
swaggerhub domain:update organization/domain/1.0.0 --file domain.json
swaggerhub domain:update organization/domain/1.0.0 --published=publish --file domain.json
swaggerhub domain:update organization/domain/1.0.0 --setdefault --file domain.json
swaggerhub domain:update organization/domain/1.0.0 --published=unpublish --setdefault --file domain.json
swaggerhub domain:update organization/domain/1.0.0 --visibility=private
See code: src/commands/domain/update.js
swaggerhub help [COMMAND]
display help for swaggerhub
USAGE
$ swaggerhub help [COMMAND]
ARGUMENTS
COMMAND command to show help for
OPTIONS
--all see all commands in CLI
See code: @oclif/plugin-help
swaggerhub integration:create
creates a new API integration from a JSON configuration file.
USAGE
$ swaggerhub integration:create OWNER/API_NAME/[VERSION]
ARGUMENTS
OWNER/API_NAME/[VERSION] API where integration will be added
OPTIONS
-f, --file=file (required) location of integration configuration file
-h, --help show CLI help
DESCRIPTION
See the documentation for configuration files:
https://github.com/SmartBear/swaggerhub-cli/tree/master/examples/integrations
When VERSION is not included in the argument, the integration will be added to be default API version.
EXAMPLE
swaggerhub integration:create organization/api/1.0.0 --file config.json
See code: src/commands/integration/create.js
swaggerhub integration:delete
deletes the integration from the given API.
USAGE
$ swaggerhub integration:delete OWNER/API_NAME/VERSION/INTEGRATION_ID
ARGUMENTS
OWNER/API_NAME/VERSION/INTEGRATION_ID Integration to delete
OPTIONS
-h, --help show CLI help
EXAMPLE
swaggerhub integration:delete organization/api/1.0.0/503c2db6-448a-4678-a310-f465429e9704
See code: src/commands/integration/delete.js
swaggerhub integration:execute
executes an integration for the given API.
USAGE
$ swaggerhub integration:execute OWNER/API_NAME/VERSION/INTEGRATION_ID
ARGUMENTS
OWNER/API_NAME/VERSION/INTEGRATION_ID Integration to execute for given API
OPTIONS
-h, --help show CLI help
EXAMPLE
swaggerhub integration:execute organization/api/1.0.0/503c2db6-448a-4678-a310-f465429e9704
See code: src/commands/integration/execute.js
swaggerhub integration:get
retieves an integration for the given API.
USAGE
$ swaggerhub integration:get OWNER/API_NAME/VERSION/INTEGRATION_ID
ARGUMENTS
OWNER/API_NAME/VERSION/INTEGRATION_ID Integration to fetch for given API
OPTIONS
-h, --help show CLI help
EXAMPLE
swaggerhub integration:get organization/api/1.0.0/503c2db6-448a-4678-a310-f465429e9704
See code: src/commands/integration/get.js
swaggerhub integration:list
list integrations on an API.
USAGE
$ swaggerhub integration:list OWNER/API_NAME/[VERSION]
ARGUMENTS
OWNER/API_NAME/[VERSION] API to list integrations on
OPTIONS
-h, --help show CLI help
EXAMPLE
swaggerhub integration:list organization/api/1.0.0
See code: src/commands/integration/list.js
swaggerhub integration:update
update the configuration of an API integration.
USAGE
$ swaggerhub integration:update OWNER/API_NAME/VERSION/INTEGRATION_ID
ARGUMENTS
OWNER/API_NAME/VERSION/INTEGRATION_ID Integration to update on the given API
OPTIONS
-f, --file=file (required) location of integration configuration file
-h, --help show CLI help
EXAMPLE
swaggerhub integration:update organization/api/1.0.0/503c2db6-448a-4678-abcd-0123456789abc --file config.json
See code: src/commands/integration/update.js
swaggerhub plugins
list installed plugins
USAGE
$ swaggerhub plugins
OPTIONS
--core show core plugins
EXAMPLE
$ swaggerhub plugins
See code: @oclif/plugin-plugins
swaggerhub plugins:inspect PLUGIN...
displays installation properties of a plugin
USAGE
$ swaggerhub plugins:inspect PLUGIN...
ARGUMENTS
PLUGIN [default: .] plugin to inspect
OPTIONS
-h, --help show CLI help
-v, --verbose
EXAMPLE
$ swaggerhub plugins:inspect myplugin
See code: @oclif/plugin-plugins
swaggerhub plugins:install PLUGIN...
installs a plugin into the CLI
USAGE
$ swaggerhub plugins:install PLUGIN...
ARGUMENTS
PLUGIN plugin to install
OPTIONS
-f, --force yarn install with force flag
-h, --help show CLI help
-v, --verbose
DESCRIPTION
Can be installed from npm or a git url.
Installation of a user-installed plugin will override a core plugin.
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
the CLI without the need to patch and update the whole CLI.
ALIASES
$ swaggerhub plugins:add
EXAMPLES
$ swaggerhub plugins:install myplugin
$ swaggerhub plugins:install https://github.com/someuser/someplugin
$ swaggerhub plugins:install someuser/someplugin
See code: @oclif/plugin-plugins
swaggerhub plugins:link PLUGIN
links a plugin into the CLI for development
USAGE
$ swaggerhub plugins:link PLUGIN
ARGUMENTS
PATH [default: .] path to plugin
OPTIONS
-h, --help show CLI help
-v, --verbose
DESCRIPTION
Installation of a linked plugin will override a user-installed or core plugin.
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
command will override the user-installed or core plugin implementation. This is useful for development work.
EXAMPLE
$ swaggerhub plugins:link myplugin
See code: @oclif/plugin-plugins
swaggerhub plugins:uninstall PLUGIN...
removes a plugin from the CLI
USAGE
$ swaggerhub plugins:uninstall PLUGIN...
ARGUMENTS
PLUGIN plugin to uninstall
OPTIONS
-h, --help show CLI help
-v, --verbose
ALIASES
$ swaggerhub plugins:unlink
$ swaggerhub plugins:remove
See code: @oclif/plugin-plugins
swaggerhub plugins:update
update installed plugins
USAGE
$ swaggerhub plugins:update
OPTIONS
-h, --help show CLI help
-v, --verbose
See code: @oclif/plugin-plugins
The SwaggerHub CLI supports plugins via the oclif plugin infrastructure.
To install a plugin
$ swaggerhub plugins:install <github-url>
To list other options related to plugins
$ swaggerhub plugins --help
An example plugin used for fetching popular JSON Schema files, can be found here: https://github.com/ponelat/swaggerhub-cli-plugin-schema
Example usage
$ swaggerhub plugins:install https://github.com/ponelat/swaggerhub-cli-plugin-schema
$ swaggerhub schema:list
angular-cli-json
ansible
apple-app-site-association
appsscript-json
#...
$ swaggerhub schema:get ansible
{
"description": "Auto-Generated JSON Schema for Ansible-stable 2.9 (https://github.com/shaded-enmity/ansible-schema-generator)",
"title": "Ansible 2.9",
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "array",
# ...
The SwaggerHub CLI is currently in an active development phase—we will not be accepting Pull Requests at this time. If you’ve found any bugs or typos, or have a feature requests or general feedback you’d like to share, please open an issue and let us know.
FAQs
SwaggerHub CLI
The npm package swaggerhub-cli receives a total of 1,693 weekly downloads. As such, swaggerhub-cli popularity was classified as popular.
We found that swaggerhub-cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.