Last updated 3 weeks ago

Redocly OpenAPI CLI

Redocly OpenAPI CLI is an open source command-line tool used to:

  • Lint, validate and bundle your OpenAPI definition(s).
  • Preview reference docs for local development.
  • Build production-ready reference docs (requires an Enterprise license key).

Redocly OpenAPI CLI does not:

  • Integrate to Redocly's API Registry (instead, integrate by connecting to your source control or upload file or URL).
  • Structure your OpenAPI repository (see create OpenAPI repo).

Redocly OpenAPI CLI can be:

Features

Currently, @redocly/openapi-cli supports these features:

  • Multifile validation. No need to bundle your file before validation.
  • Support for remote $refs
  • Configurable message levels for each rule. You can tailor your experience with @redocly/openapi-cli as you wish.
  • Lightning-fast validation. Check 1 Mb file in less than one second.
  • Human-readable error messages. Now with stacktraces and codeframes.
  • Intuitive suggestions for misspelled types or references.
  • Easy to implement custom rules. Need something? Ask us or do it yourself.
  • Bundle a multifile definition into a single file.
  • Preview reference docs.
  • Supports OAS3 and Swagger 2.

What makes this different

Unlike other OpenAPI validators, @redocly/openapi-cli defines the possible type tree of a valid OpenAPI definition and then traverses it. This approach is very similar to how compilers work and results in major performance benefits over other approaches.

Additionally, you may extend functionality by adding additional rules. Both the lint and the bundler features are following the visitor pattern for adding custom behavior on the parsed object.

Installation

Run the @redocly/openapi-cli either with npx or after installing it locally.

If using npx, enter the following:

npx @redocly/openapi-cli <command> [options]

Otherwise, install the @redocly/openapi-cli with:

npm install -g @redocly/openapi-cli

or:

yarn global add @redocly/openapi-cli

Run openapi -h to confirm the installation was successful (you'll see the usage information).

See the source in the OpenAPI-CLI GitHub repository.