-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
chore: package readmes #1695
Closed
Closed
chore: package readmes #1695
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
docs/reference/functions.md → packages/functions/docs/core-functions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Rulesets | ||
|
||
Rulesets are collections of rules written in JSON or YAML, which can be used to power powerful linting of other JSON or YAML files. Meta, we know! 😎 | ||
|
||
These rules are taking parameters, and calling functions on certain parts of another YAML or JSON object being linted. | ||
|
||
## Anatomy of a Ruleset | ||
|
||
A ruleset is a JSON or YAML file ([often the file will be called `.spectral.yaml`](../../cli/README.md#using-a-ruleset-file)), and there are two main parts. | ||
|
||
### Rules | ||
|
||
Rules might look a bit like this: | ||
|
||
```yaml | ||
rules: | ||
my-rule-name: | ||
description: Tags must have a description. | ||
given: $.tags[*] | ||
severity: error | ||
then: | ||
field: description | ||
function: truthy | ||
``` | ||
|
||
Spectral has [built-in functions](../../functions/docs/core-functions.md) such as `truthy` or `pattern`, which can be used to power rules. | ||
|
||
Rules then target certain chunks of the JSON/YAML with the `given` keyword, which is a [JSONPath](http://jsonpath.com/) (actually, we use [JSONPath Plus](https://www.npmjs.com/package/jsonpath-plus)). | ||
|
||
The example above adds a single rule that looks at the root level `tags` object's children to make sure they all have a `description` property. | ||
|
||
### Extending Rulesets | ||
|
||
Rulesets can extend other rulesets using the `extends` property, allowing you to pull in other rulesets. | ||
|
||
```yaml | ||
extends: spectral:oas | ||
``` | ||
|
||
Extends can reference any [distributed ruleset](./sharing-rulesets.md). It can be a single string, or an array of strings, and can contain either local file paths, URLs, or even NPM modules. | ||
|
||
```yaml | ||
extends: | ||
- ./config/spectral.json | ||
- https://example.org/api/style.yaml | ||
- some-npm-module | ||
``` | ||
|
||
The `extends` keyword can be combined with extra rules in order to extend and override rulesets. Learn more about that in [custom rulesets](./custom-rulesets.md). | ||
|
||
### Formats | ||
|
||
Formats are an optional way to specify which API description formats a rule, or ruleset, is applicable to. | ||
|
||
You can read more about that in [formats package](../formats/README.md). | ||
|
||
## Core Rulesets | ||
|
||
Spectral comes with two rulesets included: | ||
|
||
- `spectral:oas` - [OpenAPI v2/v3 rules](./4-openapi.md) | ||
- `spectral:asyncapi` - [AsyncAPI v2 rules](./5-asyncapi.md) | ||
|
||
You can also make your own: read more about [Custom Rulesets](../rulesets/README.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Sharing & Distributing Rulesets | ||
|
||
A [ruleset](../getting-started/3-rulesets.md) becomes infinitely more useful when other developers are using it. By itself, it's just a way of enforcing some rules on a single project, but when distributed a ruleset can become a "style guide" for enforcing consistency across a whole bunch of projects! | ||
A [ruleset](./rulesets.md) becomes infinitely more useful when other developers are using it. By itself, it's just a way of enforcing some rules on a single project, but when distributed a ruleset can become a "style guide" for enforcing consistency across a whole bunch of projects! | ||
|
||
To help you out distribute your rulesets among the others, Spectral provides a few ways to load rulesets from a variety of resources: | ||
|
||
|
@@ -38,7 +38,7 @@ extends: | |
- https://raw.githubusercontent.com/openapi-contrib/style-guides/master/apisyouwonthate.yml | ||
``` | ||
|
||
As with any ruleset, you can pass these directly to the [Spectral CLI](./2-cli.md): | ||
As with any ruleset, you can pass these directly to the [Spectral CLI](../../cli/README.md): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will this work when the package is published to NPM? |
||
|
||
```shell | ||
spectral lint -r https://example.com/some-ruleset.yml | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, first
cli
is a name of yarn workspace and a second one is the name of the command. But it sure does look odd. Maybe we should addcd packages/cli && yarn cli lint [openapi_spec_file]
or create a customcli
command in root? @P0lip wdyt?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about 6a7a4e5