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

Using overrides to disable some rules fails #2469

Closed
antusus opened this issue May 15, 2023 · 4 comments
Closed

Using overrides to disable some rules fails #2469

antusus opened this issue May 15, 2023 · 4 comments
Labels

Comments

@antusus
Copy link

antusus commented May 15, 2023

Chore summary
I'm using spectral as a JS dependency in version 5.9.2. I'm validating output json file and some paths have lots of errors that I must postpone addressing. I wanted to use overrides to disable rules but it is not working and I have no idea what I'm doing wrong.

In my root folder I have

.spectral.yml

extends: [[spectral:oas, all]]

overrides:
  - files:
      - "**#/components/schemas/Activity/properties/tags/example"
    rules:
      oas3-valid-schema-example : "info"

openapi.json

I'm including only very small portion of my file

{
  "openapi": "3.0.2",
  "info": {
    "title": "Test",
    "version": "1.0.0"
  },
  "paths": {
  },
  "components": {
    "schemas": {
      "Activity": {
        "title": "Activity",
        "type": "object",
        "properties": {
          "tags": {
            "type": "array",
            "example": "1"
          }
        }
      }
    }
  }
}

The example is not a proper array so the validation fails as expected with:

 17:24    error  oas3-valid-schema-example      `example` property type should be array                                  components.schemas.Activity.properties.tags.example

But I specified that this should be reported as info and should not fail my test.

I'm using command

spectral lint openapi.json -F error --fail-on-unmatched-globs -v

Can you tell me what I'm doing wrong?
Can I disable the oas3-valid-schema-example rule?
I was trying with path: "openapi.json#/components/schemas/Activity/properties/tags/example" and it also fails.

Additional context
If needed I've created sample project here: https://github.com/antusus/spectral-test and you should be able to use any node version.

@antusus antusus added the chore label May 15, 2023
@P0lip
Copy link
Contributor

P0lip commented May 15, 2023

Hey!
You should use Spectral 6.x. 5.9.2 does not support overrides.
With 6.x it works just fine.
image

If you chose npm/yarn installation, make sure to remove @stoplight/spectral and install @stoplight/spectral-cli instead.

@P0lip P0lip closed this as completed May 15, 2023
@antusus
Copy link
Author

antusus commented May 18, 2023

Hi,
@P0lip any suggestion what I can use to ignore those errors in version 5 of spectral?
I cannot easily upgrade to v6... looks like I have some dependency clashes.

@P0lip
Copy link
Contributor

P0lip commented May 18, 2023

Spectral v5 only lets you disable the rule entirely via exceptions. You'll need to upgrade to v6 if you want to leverage overrides.

@antusus
Copy link
Author

antusus commented May 18, 2023

Thanks for all the answers.

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

No branches or pull requests

2 participants