Skip to content
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

Path Specific Overrides Not Working #2753

Open
david-lance opened this issue Dec 5, 2024 · 0 comments
Open

Path Specific Overrides Not Working #2753

david-lance opened this issue Dec 5, 2024 · 0 comments

Comments

@david-lance
Copy link

Spectral Override Test Case

This repository demonstrates a potential issue with Spectral's override functionality when targeting specific paths within OpenAPI files.

Sample project: https://github.com/david-lance/spectral-rule-override-for-endpoint-failure.git

Issue Description

When attempting to override Spectral rules for specific paths within an OpenAPI file using JSON Pointer notation, the override does not take effect.

Test Case

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

Setup

  1. Install Spectral CLI:

    npm install -g @stoplight/spectral-cli
  2. Run the test:

    spectral lint reference/api.yaml

Expected Behavior

The rule should be disabled for the /resources/details endpoint due to the override in .spectral.yaml.

Actual Behavior

The rule is still applied despite the override configuration.

Expected Output

(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!

Actual Output

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

Additional Notes

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

Directory Structure

.
├── .spectral.yaml
├── README.md
└── reference
    ├── api.yaml
    └── shared
        └── common.yaml

Environment

Spectral Version: 6.13.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant