Azure / azure-api-style-guide

Spectral rules to check conformance to Azure API Guidelines
MIT License
45 stars 21 forks source link

Add example for overriding rules... #51

Open markweitzel opened 2 years ago

markweitzel commented 2 years ago

In Azure Ruleset Readmen we talk about overriding the rule set. We should show an example here of how to do this.

mikekistler commented 2 years ago

I've tested the override support in Spectral and it seems to work. Here's an example:

extends:
  - ../azure-api-style-guide/spectral.yaml
overrides:
  # Turn off rules for cognitive svcs APIs
  - files:
      - specification/cognitiveservices/**/*.json
    rules:
      # az-operation-id: off
      az-version-policy: off
      az-version-convention: off

Unfortunately, the override support is a feature of Spectral v6, and the VSCode plugin for Spectral currently uses Spectral v5.9, so the overrides do not work when using the Spectral VSCode plugin.

It looks like there is an effort to get the Spectral VSCode plugin updated to v6:

https://github.com/stoplightio/vscode-spectral/issues/107

mikekistler commented 2 years ago

Another Spectral issue related to rule overrides:

https://github.com/stoplightio/spectral/issues/2036