Skip to content

Commit

Permalink
Merge branch 'develop' into chore/cli/demand-ruleset-file
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip authored Jun 29, 2021
2 parents ce9e626 + 15def43 commit 3959353
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/getting-started/3-rulesets.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,29 @@ Rules then target certain chunks of the JSON/YAML with the `given` keyword, whic

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.

### JSONPath Plus

As mentioned, spectral is using JSONPath Plus which expands on the original JSONPath specification to add some additional operators and makes explicit some behaviors the original did not spell out.

Here are some convenient **additions or elaborations**:

- `^` for grabbing the **parent** of a matching item
- `~` for grabbing **property names** of matching items (as array)
- **Type selectors** for obtaining:
- Basic JSON types: `@null()`, `@boolean()`, `@number()`, `@string()`, `@array()`, `@object()`
- `@integer()`
- The compound type `@scalar()` (which also accepts `undefined` and
non-finite numbers when querying JavaScript objects as well as all of the basic non-object/non-function types)
- `@other()` usable in conjunction with a user-defined `otherTypeCallback`
- Non-JSON types that can nevertheless be used when querying
non-JSON JavaScript objects (`@undefined()`, `@function()`, `@nonFinite()`)
- `@path`/`@parent`/`@property`/`@parentProperty`/`@root` **shorthand selectors** within filters
- **Escaping**
- `` ` `` for escaping remaining sequence
- `@['...']`/`?@['...']` syntax for escaping special characters within
property names in filters
- Documents `$..` (**getting all parent components**)

### Extending Rulesets

Rulesets can extend other rulesets using the `extends` property, allowing you to pull in other rulesets.
Expand Down

0 comments on commit 3959353

Please sign in to comment.