# 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-10-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README SwaggerHub CLI ============== [![NPM](https://img.shields.io/npm/v/swaggerhub-cli.svg)](https://www.npmjs.com/package/swaggerhub-cli) 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. * [Requirements](#requirements) * [Installation](#installation) * [Setup](#setup) * [Additional configuration for SwaggerHub On-Premise](#additional-configuration-for-swaggerhub-on-premise) * [Usage](#usage) * [Commands](#commands) * [Plugins](#plugins) * [Contributing](#contributing) # Requirements Node.js 20.17 or later. # Installation ```sh-session $ npm i -g swaggerhub-cli ``` # Setup The SwaggerHub 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 SwaggerHub 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 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. ```sh-session $ swaggerhub configure ? SwaggerHub URL: https://api.swaggerhub.com ? API Key: ``` Environment variables take precedence over the configuration file created by this command. # Additional configuration for SwaggerHub On-Premise 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`](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 (-v|--version|version) swaggerhub/0.1.2 darwin-x64 node-v12.13.0 $ swaggerhub --help [COMMAND] USAGE $ swaggerhub COMMAND ... ``` # Commands * [`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: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: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:create` creates a new API / API version from a YAML/JSON file ``` USAGE $ swaggerhub api:create OWNER/API_NAME/[VERSION] [--visibility public|private] (--published publish|unpublish -f ) [--setdefault ] [-h] ARGUMENTS OWNER/API_NAME/[VERSION] API to create on SwaggerHub FLAGS -f, --file= (required) file location of API to create -h, --help Show CLI help. --published=