# swaggerhub-cli **Repository Path**: mirrors_SmartBear/swaggerhub-cli ## Basic Information - **Project Name**: swaggerhub-cli - **Description**: SwaggerHub CLI - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-25 - **Last Updated**: 2026-11-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Swagger CLI ============== [![NPM](https://img.shields.io/npm/v/swaggerhub-cli.svg)](https://www.npmjs.com/package/swaggerhub-cli) The Swagger CLI enables teams to build automation and workflows around Swagger. 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 Swagger CLI can help teams build the workflow that fits their needs. * [Requirements](#requirements) * [Installation](#installation) * [Setup](#setup) * [Using a proxy](#using-a-proxy) * [Additional configuration for Swagger Studio On-Premise](#additional-configuration-for-swagger-studio-on-premise) * [Usage](#usage) * [Commands](#commands) * [Plugins](#plugins) * [Contributing](#contributing) # Requirements * Node.js 22.9 or later. * Swagger SaaS, or Swagger Studio On-Premise 2.x. On-Premise 1.x is not supported. # Installation ```sh-session $ npm i -g swaggerhub-cli ``` # Setup The Swagger CLI can be configured through environment variables or through the [`swaggerhub configure`](#swaggerhub-configure) command. The CLI will look for the following environment variables. * `SWAGGERHUB_API_KEY` (required) – **Important: keep this key secure.** This is the Swagger API key the CLI will use for authentication. You can find your API key on the [user settings page](https://app.swaggerhub.com/settings/apiKey) in Swagger. * `SWAGGERHUB_URL` (optional, default is `https://api.swaggerhub.com`) – Customers with on-premise installations (version 2.x) need to point this to their on-premise API, which is `http(s)://{swaggerhub-host}/v1` (do not append a trailing slash). Alternatively, 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. ```sh-session $ swaggerhub configure ? Swagger URL: https://api.swaggerhub.com ? API Key: ``` Environment variables take precedence over the configuration file created by this command. # Using a proxy The CLI honors the standard proxy environment variables (lowercase variants also work): ``` export HTTPS_PROXY=http://proxy.example.com:8080 # used for https:// URLs, including the default https://api.swaggerhub.com export HTTP_PROXY=http://proxy.example.com:8080 # used for http:// URLs, e.g. an on-premise instance served over HTTP export NO_PROXY=localhost,.internal.example.com # hosts that should bypass the proxy ``` Proxy credentials can be included in the URL: `http://user:password@proxy.example.com:8080`. Always include the scheme (`http://` or `https://`) in the proxy URL. HTTPS requests are tunnelled through the proxy using `CONNECT`. If your proxy intercepts TLS, see `NODE_EXTRA_CA_CERTS` below. SOCKS proxies are not supported. # Additional configuration for Swagger Studio On-Premise If your Swagger Studio On-Premise instance uses a **self-signed or privately signed SSL certificate**, there are additional steps required to make the Swagger 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`](https://nodejs.org/api/cli.html#cli_node_extra_ca_certs_file) 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. * If the certificate is _self-signed_ (so that it is its own CA), include the certificate itself. * If the certificate is _signed by a private CA_, include the CA root and any intermediate certificates, in any order. Blank lines are allowed, but optional, between individual certificates. ``` -----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: ```sh-session 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 ``` # Usage ```sh-session $ swaggerhub COMMAND running command... $ swaggerhub --version swaggerhub-cli/0.13.0 linux-x64 node-v22.9.0 $ swaggerhub --help [COMMAND] USAGE $ swaggerhub COMMAND ... ``` # Commands * [`swaggerhub api:clone OWNER/API_NAME/VERSION NEW_VERSION`](#swaggerhub-apiclone) * [`swaggerhub api:create OWNER/API_NAME/[VERSION]`](#swaggerhub-apicreate) * [`swaggerhub api:delete OWNER/API_NAME/[VERSION]`](#swaggerhub-apidelete) * [`swaggerhub api:get OWNER/API_NAME/[VERSION]`](#swaggerhub-apiget) * [`swaggerhub api:publish OWNER/API_NAME/VERSION`](#swaggerhub-apipublish) * [`swaggerhub api:rename OWNER/API_NAME API_NEW_NAME`](#swaggerhub-apirename) * [`swaggerhub api:setdefault OWNER/API_NAME/VERSION`](#swaggerhub-apisetdefault) * [`swaggerhub api:unpublish OWNER/API_NAME/VERSION`](#swaggerhub-apiunpublish) * [`swaggerhub api:update OWNER/API_NAME/[VERSION]`](#swaggerhub-apiupdate) * [`swaggerhub api:validate OWNER/API_NAME/[VERSION]`](#swaggerhub-apivalidate) * [`swaggerhub api:validate:download-rules OWNER`](#swaggerhub-apivalidatedownload) * [`swaggerhub api:validate:local`](#swaggerhub-apivalidatelocal) * [`swaggerhub configure`](#swaggerhub-configure) * [`swaggerhub domain:clone OWNER/DOMAIN_NAME/VERSION NEW_VERSION`](#swaggerhub-domainclone) * [`swaggerhub domain:create OWNER/DOMAIN_NAME/[VERSION]`](#swaggerhub-domaincreate) * [`swaggerhub domain:delete OWNER/DOMAIN_NAME/[VERSION]`](#swaggerhub-domaindelete) * [`swaggerhub domain:get OWNER/DOMAIN_NAME/[VERSION]`](#swaggerhub-domainget) * [`swaggerhub domain:publish OWNER/DOMAIN_NAME/VERSION`](#swaggerhub-domainpublish) * [`swaggerhub domain:rename OWNER/DOMAIN_NAME DOMAIN_NEW_NAME`](#swaggerhub-domainrename) * [`swaggerhub domain:setdefault OWNER/DOMAIN_NAME/VERSION`](#swaggerhub-domainsetdefault) * [`swaggerhub domain:unpublish OWNER/DOMAIN_NAME/VERSION`](#swaggerhub-domainunpublish) * [`swaggerhub domain:update OWNER/DOMAIN_NAME/[VERSION]`](#swaggerhub-domainupdate) * [`swaggerhub help [COMMAND]`](#swaggerhub-help) * [`swaggerhub integration:create OWNER/API_NAME/[VERSION]`](#swaggerhub-integrationcreate) * [`swaggerhub integration:delete OWNER/API_NAME/VERSION/INTEGRATION_ID`](#swaggerhub-integrationdelete) * [`swaggerhub integration:execute OWNER/API_NAME/VERSION/INTEGRATION_ID`](#swaggerhub-integrationexecute) * [`swaggerhub integration:get OWNER/API_NAME/VERSION/INTEGRATION_ID`](#swaggerhub-integrationget) * [`swaggerhub integration:list OWNER/API_NAME/[VERSION]`](#swaggerhub-integrationlist) * [`swaggerhub integration:update OWNER/API_NAME/VERSION/INTEGRATION_ID`](#swaggerhub-integrationupdate) * [`swaggerhub plugins`](#swaggerhub-plugins) * [`swaggerhub plugins:add PLUGIN`](#swaggerhub-pluginsadd) * [`swaggerhub plugins:inspect PLUGIN...`](#swaggerhub-pluginsinspect) * [`swaggerhub plugins:install PLUGIN`](#swaggerhub-pluginsinstall) * [`swaggerhub plugins:link PATH`](#swaggerhub-pluginslink) * [`swaggerhub plugins:remove [PLUGIN]`](#swaggerhub-pluginsremove) * [`swaggerhub plugins:reset`](#swaggerhub-pluginsreset) * [`swaggerhub plugins:uninstall [PLUGIN]`](#swaggerhub-pluginsuninstall) * [`swaggerhub plugins:unlink [PLUGIN]`](#swaggerhub-pluginsunlink) * [`swaggerhub plugins:update`](#swaggerhub-pluginsupdate) * [`swaggerhub project:api:add OWNER/PROJECT_NAME API`](#swaggerhub-projectapiadd) * [`swaggerhub project:api:remove OWNER/PROJECT_NAME API`](#swaggerhub-projectapiremove) * [`swaggerhub project:create OWNER/PROJECT_NAME`](#swaggerhub-projectcreate) * [`swaggerhub project:delete OWNER/PROJECT_NAME`](#swaggerhub-projectdelete) * [`swaggerhub project:domain:add OWNER/PROJECT_NAME DOMAIN`](#swaggerhub-projectdomainadd) * [`swaggerhub project:domain:remove OWNER/PROJECT_NAME DOMAIN`](#swaggerhub-projectdomainremove) * [`swaggerhub project:get OWNER/PROJECT_NAME`](#swaggerhub-projectget) * [`swaggerhub project:list [OWNER]`](#swaggerhub-projectlist) * [`swaggerhub project:member:list OWNER/PROJECT_NAME`](#swaggerhub-projectmemberlist) * [`swaggerhub spectral:download OWNER/RULESET_NAME DIRECTORY`](#swaggerhub-spectraldownload) * [`swaggerhub spectral:upload OWNER/RULESET_NAME DIRECTORY`](#swaggerhub-spectralupload) ## `swaggerhub api:clone` clone an API version as a new version ``` USAGE $ swaggerhub api:clone OWNER/API_NAME/VERSION NEW_VERSION [--visibility public|private] [-h] ARGUMENTS OWNER/API_NAME/VERSION API version to clone NEW_VERSION Version identifier of the new API version FLAGS -h, --help Show CLI help. --visibility=