Closed br-tyler-milner closed 1 year ago
Hey! JSON pointer in the URI should be percent-encoded, thus you'd need to change overrides to
overrides:
- files:
- "reference/Demo.yaml#/paths/~1v2.1~1users~1%7BuserId%7D"
- "reference/Demo.yaml#/paths/~1user"
rules:
resource-names-plural: "off"
- files:
- "reference/Demo.yaml#/paths/~1v2.1~1users~1%7BuserId%7D"
rules:
path-casing: "warn"
LMK if you have any questions.
Thanks, @P0lip! I can confirm that encoding the {
}
curly braces with %7B
and %7D
does work. Feel free to close this when ready, but it would be great if the Overrides Spectral documentation page could be updated to incorporate these new encodings as it currently only mentions needing to encode /
--> ~1
and ~
--> ~0
and still shows example code that contains unencoded curly braces.
Good point re the docs - will do.
To give you some extra context behind that change - that's been a bug for a few years in a library that's used across our entire ecosystem. That gap was closed in https://github.com/stoplightio/json/pull/122, but that resulted in a slight change in the behavior which you observed here. Long story short - JSON Pointers (the most common usage in Spectral) must be percent-encoded when used inside of URIs
If you want to get the right pointer, you can run Node.js REPL
node # REPL should open
and then run
require('@stoplight/json').pathToPointer(['abc', 'def', '{}']) # this will output you the valid pointer to use in the URI
Alternatively, go to https://npm.runkit.com/@stoplight/json and run it there
Describe the bug Running Spectral outputs linter warnings/errors for paths that have rules turned off via the
overrides
in my.spectral.yaml
. The issues seems to have coincided with the update of thespectral-core
dependency from version1.18.1
to version1.18.2
as my builds were working fine before that update was made.To Reproduce I created a sample project that demonstrates this issue, which includes detailed steps to reproduce. Abbreviated steps below:
.spectral.yaml
.spectral lint Demo.yaml --ruleset .spectral.yaml --verbose
path-casing
andresource-names-plural
errors produced forpaths./v2.1/users/{userId}
, which is configured to disable those rules via ruleoverrides
.Expected behavior No errors should be output.
Screenshots![image](https://github.com/stoplightio/spectral/assets/78233128/e037428a-cf64-4277-9648-251b324ce643)
Environment:
Additional context See
README
in sample project linked above for additional details.