feat(core): allow overrides to target formats without files - #3081
Open
SahilRajputdotexe wants to merge 1 commit into
Open
SahilRajputdotexe wants to merge 1 commit into
SahilRajputdotexe wants to merge 1 commit into
Conversation
An override may now state formats instead of files, or both, and it is applied only to documents that match every selector it states. Format detection runs before overrides are resolved, so formats that are only mentioned inside an override still take part in detection. Overrides that use JSON Pointers can state formats as well. Signed-off-by: Sahil Rajput <90515841+SahilRajputdotexe@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2446.
This lets an override select documents by
formatsinstead of, or together with,files. The docs already list formats as an override target, but the schema requiredfilesand the format list was never looked at when picking an override.An override now has to state
files,formats, or both, and it applies only to documents that match every selector it states. A document whose format cannot be detected is not picked by an override that statesformats, but still matches overrides that only statefiles. Formats that are only mentioned inside an override are used when detecting a document's format. To make that work, format detection now runs before the overrides are resolved. A document with no source is only an error when some override statesfiles. Overrides that use JSON Pointers can stateformatstoo.Only OpenAPI 3.0 documents get the changed severity. Other documents linted in the same run are not affected.
I added tests for the schema,
Ruleset#fromSourceand linting throughSpectral#run. I also updateddocs/guides/4d-overrides.md, whose example was not valid YAML.Checklist
Does this PR introduce a breaking change?