From df4e1020c58945ca53d366a0f384448f1cbf0e5b Mon Sep 17 00:00:00 2001 From: "pam@stoplight.io" Date: Tue, 15 Feb 2022 16:26:16 -0700 Subject: [PATCH] docs(repo): added steps for getting rulesets --- README.md | 18 +++++++++++++----- docs/guides/2-cli.md | 8 +++++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 231aa2f94..6077c0589 100644 --- a/README.md +++ b/README.md @@ -34,20 +34,28 @@ Find more [installation methods](https://meta.stoplight.io/docs/spectral/docs/ge **Create a Ruleset** -Spectral, being a generic YAML/JSON linter, needs a ruleset in order to be able to lint files. -You can learn more about the rulesets [here](./docs/getting-started/3-rulesets.md). +Spectral, being a generic YAML/JSON linter, needs a ruleset to lint files. There are two ways to get a ruleset: -If you intend to lint an OpenAPI or AsyncAPI document, we have a few predefined rulesets you can extend to get Spectral up and running. -To reference them, you can run the following command: +1. Run this command to get our predefined rulesets based on OpenAPI or AsyncAPI: ```bash printf '{\n "extends": ["spectral:oas", "spectral:asyncapi"]\n}\n' > .spectral.json ``` +2. Create your [own ruleset](./docs/getting-started/3-rulesets.md). + **Lint** +Use this command to lint with the predefined ruleset or a ruleset stored in the same directory as your API document: + +```bash +spectral lint myapifile.yaml +``` + +Use this command to lint with a custom ruleset or one that is located in a different directory than your API document: + ```bash -spectral lint petstore.yaml +spectral lint myapifile.yaml --ruleset myruleset.json ``` ## 📖 Documentation diff --git a/docs/guides/2-cli.md b/docs/guides/2-cli.md index ad5f39398..154acbf8c 100644 --- a/docs/guides/2-cli.md +++ b/docs/guides/2-cli.md @@ -1,11 +1,17 @@ # Spectral CLI -[Once installed](../getting-started/2-installation.md), Spectral can be run via the command-line: +[Once Spectral is installed](../getting-started/2-installation.md) and [you have a ruleset](../../README.md#installation-and-usage), run Spectral via the command-line: ```bash spectral lint petstore.yaml ``` +Use this command to lint with a custom ruleset or one that is located in a different directory than your API document: + +```bash +spectral lint petstore.yaml --ruleset myruleset.json +``` + You can lint multiple files at the same time by passing on multiple arguments: ```bash