0.0.2 • Published 3 years ago
baloise-spectral-ruleset v0.0.2
spectral-ruleset
👷🚧🛠️ in development 👷🚧🛠️
Custom Spectral API Linter ruleset for Zalando RESTful API Guidelines.
Use it
# default openapi ruleset defined in .spectral.yml
npx @stoplight/spectral lint example/example-openapi.yml
# or reference the ruleset via url
npx @stoplight/spectral lint example/example-openapi.yml --ruleset https://raw.githubusercontent.com/baloise-incubator/spectral-ruleset/main/.spectral.yml
# if you're behind a proxy
PROXY=<PROXY URL> npx @stoplight/spectral lint <...>
Development
Adding a new Rule
- Choose a new, unsupported rule from the table below. For example #151 MUST specify success and error responses.
- Make sure
tests/fixtures/base-openapi.yml
satisfies the rule. - Add a test
tests/151-MUST-specify-success-and-error-responses.test.ts
that- Takes the
base-openapi.yaml
as input - Modifies it to break the new rule
- Expect that spectral finds the error (this will fail for now)
- Takes the
- Extend
.spectral.yml
with the new rule, so that the previously added test succeeds. See https://meta.stoplight.io/docs/spectral/docs/guides/4-custom-rulesets.md on how to define custom rules. - Add a :heavy_check_mark: to the table below.
- Create a PR
Setup
npm install
npm run test
npm run lint
npm run lint-fix # format source files