Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(repo): added steps for getting rulesets #2063

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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