This repository demonstrates a potential issue with Spectral's override functionality when targeting specific paths within OpenAPI files.
When attempting to override Spectral rules for specific paths within an OpenAPI file using JSON Pointer notation, the override does not take effect.
The test case includes:
- A simple rule checking for Cache-Control headers
- An attempt to override this rule for a specific endpoint using path notation
- A minimal OpenAPI specification demonstrating the issue
-
Install Spectral CLI:
npm install -g @stoplight/spectral-cli
-
Run the test:
spectral lint reference/api.yaml
The rule should be disabled for the /resources/details
endpoint due to the override in .spectral.yaml
.
The rule is still applied despite the override configuration.
(base) david.lance@David-Lance spectral-rule-override-for-endpoint-failure % spectral lint test-cases/failing/api.yaml --verbose
Found 57 rules (46 enabled)
Linting /Users/david.lance/Workspace/spectral-rule-override-for-endpoint-failure/reference/api.yaml
No results with a severity of 'error' found!
bash-3.2$ spectral lint reference/api.yaml
/Users/david.lance/Workspace/spectral/spectral-rule-no-store/test-cases/shared/common.yaml
5:20 error cache-control-header-rule Success responses should contain a `Cache-Control` header value of `no-store`. components.headers.CacheControlHeader.description
File-level overrides (without path specification) work as expected. Also found that the **
prefix was necessary to target the file.:
overrides:
- files:
- "**/reference/api.yaml" # This works
.
├── .spectral.yaml
├── README.md
└── reference
├── api.yaml
└── shared
└── common.yaml
Feel free to open issues or pull requests if you have suggestions or improvements.