Error when handling formats if json rulesets are extended #2362
Labels
c/spectral
p/medium
released
reviewed-medium
Medium bug was reviewed & kept as medium
t/bug
Something isn't working
triaged
Error when handling formats if json rulesets are extended
When using extended json rulesets, spectral is running into a type error. Running rulesets without the
extends
keyword individually works perfectly fine. This is a bug report for json rulesets only. YAML rulesets are working as expected.To Reproduce
We are running spectral from nodejs as described in here: https://meta.stoplight.io/docs/spectral/eb68e7afd463e-spectral-in-java-script#load-rulesets-and-api-specification-files.
When running rulesets individually, spectral runs and return the expected results. If extending a rulesets with a custom ruleset, e.g.:
oas-spectral.json
and
mqc-spectral.json
(this is the one, that is failing ❗️❗️❗️)we are running into the following error:
Expected behavior and how to fix
When running spectral from JavaScript, it should be possible to use the
extends
keyword in custom json rulesets.I invested some time to go through your code and I think I found the lines that are not correct. When changing https://github.com/stoplightio/spectral/blob/develop/packages/core/src/ruleset/rule.ts#L163-L167 to the following:
everything works as expected. (Changed the usage of
this
keyword) 👍🏻Screenshots
Environment:
Library versions:
"@stoplight/spectral-core": "^1.15.2",
"@stoplight/spectral-parsers": "^1.0.2",
"@stoplight/spectral-ruleset-bundler": "^1.5.0",
"@stoplight/spectral-runtime": "^1.1.2",
OS: macOS 12.2.1
Node version: any
If you need further information, please let me know. 🚀
The text was updated successfully, but these errors were encountered: