All Projects → stoplightio → spectral-action

stoplightio / spectral-action

Licence: Apache-2.0 license
GitHub Action wrapper for Spectral - a JSON/YAML/OpenAPI/AsyncAPI/etc linter with custom rule support.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
Dockerfile
14818 projects

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@v2

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

Inputs

  • file_glob: Pattern describing the set of files to lint. Defaults to *.oas.{json,yml,yaml}. (Note: Pattern syntax is documented in the fast-glob package documentation)
  • spectral_ruleset: Custom ruleset to load in Spectral. When unspecified, will try to load the default .spectral.yaml ruleset if it exists.

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}"]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].