Skip to content

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI v2 & v3.

License

Notifications You must be signed in to change notification settings

james-wang-sage/spectral

This branch is 741 commits behind stoplightio/spectral:develop.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b8022fb Β· Jun 16, 2021
Jun 16, 2021
Mar 5, 2020
Jan 4, 2021
Mar 5, 2021
Mar 5, 2020
Jun 10, 2021
Jun 10, 2021
Jun 10, 2021
May 10, 2021
May 24, 2021
Jun 16, 2021
Jun 7, 2021
Jun 10, 2021
Aug 29, 2019
May 14, 2020
Oct 5, 2020
Jun 7, 2021
Mar 5, 2020
Oct 10, 2019
May 12, 2021
Oct 5, 2020
Mar 16, 2020
Apr 9, 2021
Nov 6, 2020
Apr 17, 2020
Dec 4, 2018
Apr 26, 2021
Mar 5, 2021
Jun 16, 2021
Jun 10, 2021
Jun 16, 2021
Jun 16, 2021
May 29, 2020
Jun 10, 2021
Apr 29, 2021
Nov 17, 2020
Jun 16, 2021
Nov 17, 2020
Jun 16, 2021

Repository files navigation

Demo of Spectral linting an OpenAPI document from the CLI CircleCI NPM Downloads Treeware (Trees)

  • Custom Rulesets: Create custom rules to lint JSON or YAML objects
  • Ready-to-use Rulesets: Validate and lint OpenAPI v2 & v3 and AsyncAPI Documents
  • JSON Path Support: Use JSON path to apply rules to specific parts of your objects
  • Ready-to-use Functions: 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.
  • Custom Functions: Create custom functions for advanced use cases
  • JSON Validation: Validate JSON with Ajv

Demo of Spectral linting an OpenAPI document from the CLI

Overview

🧰 Installation and Usage

Install

npm install -g @stoplight/spectral

# OR

yarn global add @stoplight/spectral

Find more installation methods in our documentation.

Lint

spectral lint petstore.yaml

πŸ“– Documentation and Community

ℹ️ Support

If you need help using Spectral or have a support question, please use GitHub Discussions. It's also a great place to share your rulesets, or tools that leverage Spectral.

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

❓ 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). It's mostly been abandoned now, and is JavaScript not TypeScript.

βš™οΈ Integrations

🏁 Help Others Utilize Spectral

If you're using Spectral for an interesting use case, contact us for a case study. We'll add it to a list here. Spread the goodness πŸŽ‰

πŸ‘ Contributing

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

πŸŽ‰ Thanks

πŸ“œ License

Spectral is 100% free and open-source, under Apache License 2.0.

🌲 Sponsor Spectral by Planting a Tree

This package is Treeware so if you would like to thank us for creating it, we ask that you buy the world a tree.

About

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI v2 & v3.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 97.7%
  • JavaScript 1.3%
  • Other 1.0%