JSONPath selects values within a JSON or YAML document. In API linting, a Spectral rule puts one or more JSONPath expressions in `given` to find OpenAPI elements; its `then` checks the values found. A rule can therefore target the API version, parameter names, operations, or responses without checking every element. section 18.3.2 section 18.5
Start with the smallest expression that selects the elements you need:
- `$` is the document root, and `$.info.version` selects the version property of the root `info` object. section 18.5.1
- `*` selects an object's values or an array's items; `$.paths.*[post,put].responses` selects response objects for POST and PUT operations. section 18.5.2
- `..` searches through the document, while `[?(conditions)]` filters matches. `$..parameters[?(@.in === "query" || @.in === "path")]` selects query and path parameters. section 18.5.2
Check query-parameter naming
Set a rule's `given` to `$..parameters[?(@.in === "query")].name`, then apply Spectral's `casing` function with the `camel` option. A query parameter named `buyPRice` is reported because its name is not camel-cased. section 18.3.2
Test a new selector before adding its real check: temporarily use Spectral's `undefined` function in `then` and lint a valid, realistic OpenAPI document. The reported locations reveal what `given` found. Prefer several clear paths over one complex path when possible; a broad recursive search can also select unintended schema properties. section 18.5.1 section 18.5.2
For Spectral rules, consult JSONPath Plus documentation when an expression's behavior matters: Spectral uses that implementation, which includes features beyond standardized JSONPath. section 18.5


