Closed derbylock closed 1 year ago
What do your transitive dependencies look like?
You might have mixed versions of @stoplight/json
and that would cause the issue.
If you use Yarn v1, could you run npx yarn-deduplicate --packages @stoplight/json
? For Yarn v2/v3, one can use yarn dedupe
to achieve that.
This is what I get locally when I run Spectral
Thanks, it seems like I have globally installed spectral which has broken modules. When I run it from locally created ./node_modules/.bin/spectral evrything works like in your screenshot.
But anyway it breaks previous logic. Previously such errors were with full path, e.g.
paths./api/v1/clients/{client_id}/test-runs/{test_run_id}.get.responses[200].content.application/json.schema.properties.error.type
which matches the specified given:
given: "$.paths.*.*.responses.*.content.application/json.schema.properties.error.type"
Now its path is not related to paths.
From my point of view, it should not have error in output for the path components.schemas.Error.type
because the rule validates exactly path and without path information it is very difficult to determine the original reason of the error. Previous logic worked much better.
The issue is caused by the type set on Error
, so the path we output now is expected.
components:
schemas:
Error:
type: string # this is what causes the error
That logic is always meant to show the actual location that violated the rule (looks like there was some minor bug in the previous logic that didn't quite did that), and in that case it's the type keyword under the Error component, so the outcome it expected.
Well, if this is the expected behavior, I think the best thing we can do is just change our tools to match that.
Describe the bug After updating to 1.18.2, spectral begins incorrectly showing path if there are any $ref usages in path.
To Reproduce
and rules in rules.yaml:
given
property of the rule.✖ 1 problem (0 errors, 1 warning, 0 infos, 0 hints)
57:27 warning custom_check "string" must match the pattern "^object$" paths./api/v1/clients/{client_id}/test-runs/{test_run_id}.get.responses[200].content.application/json.schema.properties.error.type 79:27 warning custom_check "string" must match the pattern "^object$" paths./api/v1/clients/{client_id}/test-runs/{test_run_id}.post.responses[200].content.application/json.schema.properties.error.type