@stoplight/spectral
A flexible object linter with out of the box support for OpenAPI v2 and v3.
Last updated 2 days ago by rossmcd .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @stoplight/spectral 
SYNC missed versions from official npm registry.

Spectral logo

CircleCI NPM Downloads Treeware (Trees)

A flexible JSON/YAML linter, with out of the box support for OpenAPI v2/v3 and AsyncAPI v2.

Demo of Spectral linting an OpenAPI document from the CLI

Spectral Features

  • Create custom rules to lint JSON or YAML objects
  • Ready-to-use rules to validate and lint:
    • OpenAPI v2 and v3 documents
    • AsyncAPI v2 documents
  • Use JSON path to apply rules to specific parts of your objects
  • Built-in set of functions to help create custom rules. Functions include pattern checks, parameter checks, alphabetical ordering, a specified number of characters, provided keys are present in an object, etc.
  • Create custom functions for advanced use cases
  • Validate JSON with Ajv

Installation

npm install -g @stoplight/spectral

# OR

yarn global add @stoplight/spectral

Find more installation methods in our documentation.

Documentation

Take a look at our getting started documentation, then peek through some of our guides:

FAQs

How is this different to AJV

Ajv is a JSON Schema validator, and Spectral is a JSON/YAML linter. Instead of just validating against JSON Schema, it can be used to write rules for any sort of JSON/YAML object, which could be JSON Schema, or OpenAPI, or anything similar. Spectral does expose a schema function that you can use in your rules to validate all or part of the target object with JSON Schema (we even use Ajv used under the hood for this), but that's just one of many functions.

I want to lint my OpenAPI documents but don't want to implement Spectral right now.

No problem! A hosted version of Spectral comes free with the Stoplight platform. Sign up for a free account here.

What is the difference between Spectral and Speccy

Speccy was a great inspiration for Spectral, but was designed to work only with OpenAPI v3. Spectral can apply rules to any JSON/YAML object (including OpenAPI v2/v3 and AsyncAPI).

Speccy has been abandoned, but Spectral is steaming ahead, adding loads of functionality like custom functions, exceptions, and AsyncAPI support.

Contributing

If you are interested in contributing to Spectral, check out CONTRIBUTING.md.

Integrations

License

Spectral is 100% free and open-source, under the MIT license. Use it however you want.

This package is Treeware. If you use it in production, then we ask that you buy the world a tree - the office has enough coffee already!

Thanks

Support

If you have a bug or feature request, please create an issue.

If you need help using Spectral or have a support question, please use the Stoplight Community forum. We've created an open source category for these questions. It's also a great place to share your implementations.

If you want to discuss something in private, you can reach out to Stoplight support at support@stoplight.io.

Current Tags

  • 5.4.0-beta1                                ...           beta (a month ago)
  • 5.4.0                                ...           latest (2 days ago)

80 Versions

  • 5.4.0                                ...           2 days ago
  • 5.4.0-beta1                                ...           a month ago
  • 5.3.0                                ...           2 months ago
  • 5.2.0                                ...           2 months ago
  • 5.1.0                                ...           3 months ago
  • 5.0.0                                ...           5 months ago
  • 5.0.0-beta4                                ...           5 months ago
  • 5.0.0-beta3                                ...           5 months ago
  • 5.0.0-beta2                                ...           6 months ago
  • 5.0.0-beta1                                ...           7 months ago
  • 4.2.0                                ...           8 months ago
  • 4.2.0-beta5                                ...           8 months ago
  • 4.2.0-beta4                                ...           8 months ago
  • 4.2.0-beta3                                ...           8 months ago
  • 4.2.0-beta2                                ...           8 months ago
  • 4.2.0-beta                                ...           8 months ago
  • 4.1.1                                ...           9 months ago
  • 4.1.1-beta4                                ...           9 months ago
  • 4.1.1-beta3                                ...           9 months ago
  • 4.1.1-beta2                                ...           9 months ago
  • 4.1.1-beta                                ...           9 months ago
  • 4.1.0                                ...           9 months ago
  • 4.1.0-beta3                                ...           9 months ago
  • 4.1.0-beta2                                ...           9 months ago
  • 4.1.0-beta1                                ...           9 months ago
  • 4.0.3                                ...           9 months ago
  • 4.0.2                                ...           10 months ago
  • 4.0.1                                ...           10 months ago
  • 4.0.0                                ...           a year ago
  • 4.0.0-beta.10                                ...           a year ago
  • 4.0.0-beta.9                                ...           a year ago
  • 4.0.0-beta.8                                ...           a year ago
  • 4.0.0-beta.7                                ...           a year ago
  • 4.0.0-beta.6                                ...           a year ago
  • 4.0.0-beta.4                                ...           a year ago
  • 0.0.0                                ...           a year ago
  • 4.0.0-beta.3                                ...           a year ago
  • 4.0.0-beta1                                ...           a year ago
  • 3.1.0                                ...           a year ago
  • 3.0.5                                ...           a year ago
  • 3.0.4                                ...           a year ago
  • 3.0.3                                ...           a year ago
  • 3.0.2                                ...           a year ago
  • 3.0.1                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 2.4.0                                ...           a year ago
  • 2.3.2                                ...           a year ago
  • 2.3.1                                ...           a year ago
  • 2.3.0                                ...           a year ago
  • 2.2.0                                ...           a year ago
  • 2.1.1                                ...           a year ago
  • 2.1.0                                ...           a year ago
  • 2.0.6                                ...           a year ago
  • 2.0.5                                ...           a year ago
  • 2.0.4                                ...           a year ago
  • 2.0.3                                ...           a year ago
  • 2.0.2                                ...           a year ago
  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.2.0                                ...           a year ago
  • 1.1.2                                ...           a year ago
  • 1.1.1                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 0.1.2-beta.6                                ...           a year ago
  • 0.1.2-beta.5                                ...           a year ago
  • 0.1.2-beta.4                                ...           a year ago
  • 0.1.2-beta.3                                ...           a year ago
  • 0.1.2-beta.2                                ...           a year ago
  • 0.1.2-beta.1                                ...           2 years ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
  • 0.1.0-beta.5                                ...           2 years ago
  • 0.1.0-beta.4                                ...           2 years ago
  • 0.1.0-beta.3                                ...           2 years ago
  • 0.1.0-beta.2                                ...           2 years ago
  • 0.1.0-beta.1                                ...           2 years ago
  • 0.1.1-beta.1                                ...           2 years ago
Downloads
Today 0
This Week 151
This Month 168
Last Day 7
Last Week 6
Last Month 122
Dependencies (24)
Dev Dependencies (46)

Copyright 2014 - 2016 © taobao.org |