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

cannot override based on formats #2446

Open
rittneje opened this issue Mar 31, 2023 · 1 comment
Open

cannot override based on formats #2446

rittneje opened this issue Mar 31, 2023 · 1 comment
Labels
enhancement New feature or request triaged

Comments

@rittneje
Copy link

For support questions, please use the Stoplight Discord Community. This repository's issues are reserved for feature requests and bug reports. If you are unsure if you are experiencing a bug, our Discord is a great place to start.

Please delete this section, any any sections below that you don't use, before creating the issue.

Describe the bug

The docs say you can apply overrides to particular formats. https://docs.stoplight.io/docs/spectral/293426e270fac-overrides

However, there does not seem to be a way to do this properly.

If I create a config like so:

extends:
- "spectral:oas"
- "spectral:asyncapi"
overrides:
- formats: ["oas3_0"]
  rules:
    operation-description: "info"

I get an error

�[31mError running Spectral!�[39m
�[31m�[39mError #1: �[31mmust have required property 'files'�[39m
�[31m          at                     …./../../snapshot/project/packages/core/src/ruleset/validation/errors.ts:85      return new RulesetValidationError(inferErrorCode(path, error.keyword), error.message ?? 'unknown error', path)…�[39m
�[31m          at flatMa…                                                                                                                                                                                                             �[39m
�[31m          at convertAjvError…    …./../../snapshot/project/packages/core/src/ruleset/validation/errors.ts:79      return filteredErrors.flatMap(error => …                                                                       �[39m
�[31m          at assertValidRulese…  …./../../snapshot/project/packages/core/src/ruleset/validation/assertions.ts:26  throw new AggregateError(convertAjvErrors(validate.errors ?? []))…                                             �[39m
�[31m          at new Rulese…         …./../../snapshot/project/packages/core/src/ruleset/ruleset.ts:64                assertValidRuleset({ extends: [], ...def })…                                                                   �[39m

As per the error, files is required, even though I don't intend to filter by file name.

If I try to add something for files, it seems to do a union rather than an intersection.

extends:
- "spectral:oas"
- "spectral:asyncapi"
overrides:
- files: ["*"]
  formats: ["oas3_0"]
  rules:
    operation-description: "info"

That is, it applies the override to every file, regardless of format.

To Reproduce

See above.

Expected behavior

There should be a way to override rules for particular formats. Specifying both files and formats should use intersection logic not union logic. (If union logic is desired you should just make two entries.)

Environment (remove any that are not applicable):

  • Library version: 6.6.0
@mnaumanali94 mnaumanali94 added the t/bug Something isn't working label Apr 6, 2023
@P0lip P0lip removed the t/bug Something isn't working label Apr 25, 2023
@P0lip
Copy link
Contributor

P0lip commented Apr 25, 2023

We currently don't allow overrides based on formats alone.
The documentation is possibly a tad misleading here.
As things stand, you always need to specify files.

@P0lip P0lip added the enhancement New feature or request label Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triaged
Projects
None yet
Development

No branches or pull requests

3 participants