Choose the most appropriate installation method for your needs:
- Install locally, using
npmto make theredoclycommand available on your system. - Use
npxto get the tool at runtime rather than installing it. - The command is also available through Docker.
Before you begin, make sure you have the newest version of npm.
To install Redocly CLI locally:
- In your CLI,
cdto your project's directory. - Enter the following command:
npm i @redocly/cli@latest- (Optional) Run
redocly --versionto confirm that the installation was successful and the currently-installed version of the tool.
npx is npm's package runner. It installs and runs a command without installing it globally.
Use this approach where you can't install a new command, or in a CI context where the command is only used a handful of times.
To run Redocly CLI with npx:
Replace
redoclywithnpx @redocly/cli@latestto prepend Redocly CLI commands.npx @redocly/cli@latest <command> [options]
For example, to run redocly lint on a file named openapi.yaml, use the following command:
npx @redocly/cli@latest lint openapi.yamlRedocly CLI is available as a pre-built Docker image in Docker Hub and GitHub Packages.
Before you begin, make sure you have Docker installed.
To run Redocly CLI commands inside a docker container:
- Pull the image:
docker pull redocly/cli- To give a Docker container access to your OpenAPI description files, mount the containing directory as a volume:
docker run --rm -v $PWD:/spec redocly/cli lint openapi.yamlThis example assumes that the API description file is in your current working folder.
To run the CLI tool behind a proxy, you can use the HTTP_PROXY and HTTPS_PROXY environment variables to configure the proxy settings. These environment variables specify the proxy server for HTTP and HTTPS traffic, respectively.
To set the proxy environment variables:
- Open a terminal and use the following command:
export HTTP_PROXY=http://your-http-proxy-server:portTo directly include the proxy environment variables in a Redocly CLI command:
Prepend the command with the environment variable and its value.
For example:
HTTPS_PROXY=https://your-https-proxy-server:port redocly lint --extends minimal openapi.yaml
- Set up autocomplete for Redocly CLI.
- Check the full list of Redocly CLI commands available.
- Try things out with the Museum Example API.