-
-
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
Add rule exceptions per operation or path #1558
Comments
for json how about a
|
Per-Line or per-block rule diablement via YAML comments seems more natural than having to construct the property path in the config. Parsers generally ignore YAML comments so it is safe to do as well. For example Disable rules for single line: foo: true # spectral-disable-line rule1 rule2 Disable rules for all following lines: # spectral-disable rule1 rule2
foo: true
# spectral-enable rule1 rule2 |
As I said above, this use case is being handled with Overrides, but if you would like to take a swing at implementing it the way you'd like that would be very welcome. |
User story.
As a user, I want to be able to add exceptions, per operation, to certain rules in the open API spec to ignore failures.
This is related to, but different from the ask in #747 which was closed by providing the capability to have exceptions in rulesets via #939. The solution for that issue turns off the issue for the entire API spec.
We are asking for the rulesets to apply on the entire API spec, except on certain operations/APIs that are explicitly marked as exceptions. This is very similar to eslint's
// eslint-disable-line no-use-before-define.
Is your feature request related to a problem?
Yes, today we do not have the flexibility to not apply certain rules on certain APIs. We can only turn off all rules using #939 or
—skip-rule
. This is not ideal because these options turn off the rule on the entire API spec. We need to be able to turn off the rule per* operation.Describe the solution you'd like
The solution we'd like is a comment that can be added to the yaml or the json. In the following example, we do not want spectral to alert us on the rule operation-default-response to apply on a specific operation (post):
Note that this rule will still fire on all other operations/APIs in this API spec. You can see how this comment can be moved to the path level and apply to all operations on a certain path as well.
This works for yaml files, since yaml supports comments. However, json does not support comments. Open to suggestions on other approaches to achieve this usecase of turning off rules per operation.
The text was updated successfully, but these errors were encountered: