stoplightio / spectral-action

GitHub Action wrapper for Spectral - a JSON/YAML/OpenAPI/AsyncAPI/etc linter with custom rule support.
https://stoplight.io/open-source/spectral
Apache License 2.0
85 stars 46 forks source link

Spectral Linter Action

This action uses Spectral from Stoplight to lint your OpenAPI documents, or any other JSON/YAML files.

Usage

See action.yml

name: Run Spectral on Pull Requests

on:
  - pull_request

jobs:
  build:
    name: Run Spectral
    runs-on: ubuntu-latest
    steps:
      # Check out the repository
      - uses: actions/checkout@v3

      # Run Spectral
      - uses: stoplightio/spectral-action@latest
        with:
          file_glob: 'doc/api/*.yaml'

Inputs

Configuration

Spectral Action will respect your Spectral Rulesets, which can be defined, extended, and overriden by placing .spectral.yml in the root of your repository.

However, if you'd like to simply use a core ruleset without additional configuration, create a .spectral.yml in you repository's root with only the contents: extends: ["spectral:{rulesetTagHere}"]