SwaggerHub CLI

0.11.0 · active · verified Wed Apr 22

The SwaggerHub CLI is a command-line interface tool designed to enable automation and streamline workflows around SwaggerHub. It allows teams to integrate API lifecycle management directly into their CI/CD pipelines, supporting operations such as creating new APIs, updating existing API versions, and managing API states (e.g., marking versions as published or default). The current stable version is `0.11.0`. The package exhibits an active release cadence, with minor versions frequently introducing new features and improvements, often leveraging the `oclif` framework. Its primary differentiator is providing robust command-line access to SwaggerHub functionalities, making it ideal for programmatic API management and governance.

Common errors

Warnings

Install

Imports

Quickstart

Installs the CLI globally, demonstrates interactive configuration or environment variable setup, and runs basic commands like listing APIs and validating a local spec.

npm i -g swaggerhub-cli

# Configure interactively (alternative: set environment variables)
swaggerhub configure
# ? SwaggerHub URL: https://api.swaggerhub.com
# ? API Key: <your-api-key>

# Or configure using environment variables for non-interactive setups (e.g., CI/CD)
# export SWAGGERHUB_API_KEY="shub-api-key-123"
# export SWAGGERHUB_URL="https://api.swaggerhub.com"

# List all APIs accessible with the configured key
swaggerhub api:list

# Example: Validate a local API definition file
# Create a dummy OpenAPI spec file for validation
echo 'openapi: 3.0.0\ninfo:\n  title: My Test API\n  version: 1.0.0\npaths: {}\n' > my-api.yaml
swaggerhub api:validate:local my-api.yaml

# Clean up
rm my-api.yaml

view raw JSON →