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

Docs: Overrides first example is invalid #2795

Open
Relequestual opened this issue Mar 17, 2025 · 0 comments
Open

Docs: Overrides first example is invalid #2795

Relequestual opened this issue Mar 17, 2025 · 0 comments

Comments

@Relequestual
Copy link

Relequestual commented Mar 17, 2025

Using Spectral 6.14.2.
Docs: https://docs.stoplight.io/docs/spectral/293426e270fac-overrides

overrides:
  formats:
    - json-schema-draft7
  files:
    - schemas/**/*.draft7.json
  rules:
    valid-number-validation:
      given:
        - $..exclusiveMinimum
        - $..exclusiveMaximum
      then:
        function: schema
        functionOptions:
          type: number

The value of overrides must be an array, although this isn't clearly documented.

Using this config results in the following error:

Error running Spectral!
Error #1: must be array
          at                     …dation/errors.js:57  return new RulesetV…
          at flatMap                                                       
          at convertAjvErrors    …dation/errors.js:51  return filteredErro…
          at assertValidRuleset  …on/assertions.js:19  throw new es_aggreg…
          at new Ruleset         …leset/ruleset.js:31  (0, index_1.assertV…

The error message is not ideal. What must be an array? Who knows.

I can't seem to find a JSON Schema for the config file. Do you have one?

In addition, per documentation, if the function is schema, the functionOptions object shown in the example, must be nested under schema.

Error running Spectral!
Error #1: "schema" function has invalid options specified. Example valid options: { "schema": { /* any JSON Schema can be defined here */ } , { "schema": { "type": "object" }, "dialect": "auto" }
          at                   …set/function.js:101  throw new Aggregate…
          at map                                                         
          at validator         …set/function.js:101  throw new Aggregate…
          at validateFunction  …tors/function.js:17  validator(opts);    
          at validate26        …ompile/index.ts:171  const makeValidate …
@Relequestual Relequestual changed the title Docs overrides first example is invalid Docs: Overrides first example is invalid Mar 17, 2025
@mnaumanali94 mnaumanali94 self-assigned this Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants