Skip to content

Commit

Permalink
docs(repo): added steps for getting rulesets
Browse files Browse the repository at this point in the history
  • Loading branch information
pamgoodrich authored and P0lip committed Feb 17, 2022
1 parent fb756f2 commit df4e102
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion docs/guides/2-cli.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit df4e102

Please sign in to comment.