-
-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error disabling an extended ruleset in an extended ruleset #1352
Comments
@adanilev |
Hi @P0lip, ugh, I'm an idiot but there's still a problem. No error is thrown but the rules are not getting disabled when I use |
Hey @adanilev. // .spectral.json
{
"extends": [["spectral:oas", "off"]],
"rules": {
"path-params": true
}
} Do you load such a ruleset directly or do you load something as follows? {
"extends": "./foo.json"
} where The latter example (ruleset extending foo.json) is indeed somewhat broken - it doesn't seem like we disable rules. |
@P0lip, yep, that's the issue I'm referring to. |
I ran into this same problem in the last few days and I think I understand what's going on here. I think that the way "extends" works -- it enables or disables rules in the "parent" ruleset based on the second value in the array -- "on", "off", or "recommended" -- not whether the rule is actually enabled in the parent ruleset. So for this case: foo.yaml
All rules are off except So then if we have: bar.yaml
it will enable all the "recommended" rules in the So this behavior may not be intuitive, but I think it does match the documentation. |
Based on the above, I thought I saw a path to working-around this issue -- just set all the So I would like to propose a change to the way extends works. The most straightforward change would be to change the way If there is concern about this kind of behavioral change, another possibility is to support a third element in the array to specify how to set "recommended". So For this to fully work, we'd also need the "enabling" syntax to update "recommended", again either transparently or with a second option.
Would enable the rule and set "recommended" to |
Well ... curiously ... things work a bit differently if you don't disable all the rules with So it does seem like there is an inconsistency here. If |
Describe the bug
When I structure my rules like so:
index.json
rules-one.json
...and then load them like so:
I get the following error:
This does not occur if:
spectral:oas
rulesindex.json
instead ofrules-one.json
I also tried to extend/disable the spectral rules in
index.json
and then enable specific ones inrules-one.json
but that didn't work (they don't get enabled).I printed the ruleset that fails to validate and it's an IIFE that starts with:
(function (root, factory) { if (typeof define === \"function\" && define.amd) {
To Reproduce
Expected behavior
The rules load successfully and allow me to disable an extended ruleset, in an extended ruleset, and then selectively enable them.
Environment (remove any that are not applicable):
Additional context
I organised my rules to be aligned with the OAS schema objects (e.g.
operation-object.json
) to keep things manageable. I want to enable specificspectral:oas
rules alongside related, custom ones.Workaround is to extend/disable in
index.json
and then enable specific rules there too.The text was updated successfully, but these errors were encountered: