Skip to content

onlineplasticsgroup/spectral-jsonapi-ruleset

 
 

Repository files navigation

spectral-jsonapi-ruleset

Node.js CI CodeQL

A Stoplight/Spectral linting ruleset for the JSON:API specification, supporting both v1.0 and v1.1.

Installation

For ways to integrate this ruleset into your Spectral linting suite. See Sharing & Distributing Rulesets at https://meta.stoplight.io/

Organization

.spectral.yml - Spectral Ruleset for JSON:API v1.0

jsonapi-1.1.yml - Spectral Ruleset for JSON:API v1.1

Point Spectral at the file matching the JSON:API version your API targets:

# Lint a v1.0 API definition
spectral lint your-api.yml -r ./.spectral.yml

# Lint a v1.1 API definition
spectral lint your-api.yml -r ./jsonapi-1.1.yml

The v1.0 ruleset extends - spectral:oas, spectral's built-in OAS linting rules.

jsonapi-1.1.yml is an additive overlay: it extends .spectral.yml and only redefines the rules that changed in v1.1 (the ext/profile media type parameters, the expanded links object members, the jsonapi object ext/profile/meta members, and the lid local identifier). Everything else is inherited unchanged. (Note: Spectral does not inherit aliases through extends, so the alias block is duplicated in the overlay; keep the two in sync.)

The rules are generally organized by the JSON:API specification section the rule is mentioned in. Each rule notes the section url it realates to.

examples folder contains valid and invalid OAS3.1 examples. examples/valid is linted against the v1.0 ruleset and examples/valid-1.1 against the v1.1 ruleset.

Contributing

In lieu of a formal style guide (I know... ironic 😁):

  • Take care to maintain the existing coding format.
  • Make needed adjustments to valid example
  • Verify all linting PASS: npm test

License

MIT License

About

A Stoplight/Spectral linting ruleset for the JSON:API specification.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Shell 100.0%