Need help with openapi-cli?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

Redocly
264 Stars 30 Forks MIT License 644 Commits 62 Opened issues

Description

⚒️ OpenAPI CLI toolbox with rich validation and bundling features.

Services available

!
?

Need anything else?

Contributors list

OpenAPI CLI toolset

OpenAPI CLI toolbox with rich validation and bundling features.

Travis (.org) npm (scoped) NPM

OpenAPI 3 CLI toolset

Features

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

  • [x] Multifile validation. No need to bundle your file before validation.
  • [x] Lightning-fast validation. Lint a 1 Mb file in less than one second.
  • [x] Built-in rules for common validations.
  • [x] Configurable severity levels for each rule.
  • [x] Human-readable error messages with codeframes and stylish format options.
  • [x] Intuitive suggestions for misspelled types or references.
  • [x] Easy to implement custom rules.
  • [x] Bundle a multifile definition into a single file.
  • [x] Decorators to modify a validated definition during bundling.
  • [x] Preview reference docs for local development.
  • [x] Support for OpenAPI 2 (fka Swagger) and OpenAPI 3.0.
  • [x] Basic Support for OpenAPI 3.1

What makes this tool different

Unlike other OpenAPI linters,

@redocly/openapi-cli
defines the possible type tree of a valid OpenAPI definition and then traverses it. This approach is very similar to how linters for programming languages work and results in major performance benefits over other approaches. Extend functionality at different points in the lifecycle with preprocessors, rules, and decorators.

Usage

Node

npx @redocly/openapi-cli lint path-to-root-file.yaml

Docker

To give the docker container access to the OpenAPI definition files, you need to mount the containing directory as a volume. Assuming the OAS definition is rooted in the current working directory, you need the following command:

docker run --rm -v $PWD:/spec redocly/openapi-cli lint path-to-root-file.yaml

To build and run with a local image, run the following from the project root:

docker build -t openapi-cli .
docker run --rm -v $PWD:/spec openapi-cli lint path-to-root-file.yaml

Read the docs

Credits

Thanks to graphql-js and eslint for inspiration of the definition traversal approach and to Swagger, Spectral, and OAS-Kit for inspiring the ruleset.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.