stoplightio / spectral

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI (v3.1, v3.0, and v2.0), Arazzo v1.0, as well as AsyncAPI v2.x.
https://stoplight.io/spectral
Apache License 2.0
2.45k stars 234 forks source link

cannot use builtin functions from override rule #2447

Closed rittneje closed 1 year ago

rittneje commented 1 year ago

Describe the bug

If I do this:

extends:
- "spectral:oas"
- "spectral:asyncapi"
aliases:
  OperationObject:
    - "#PathItem[get,put,post,delete,options,head,patch,trace]"
  PathItem:
    - $.paths[*]
overrides:
- files: ["*"]
  rules:
    operation-description:
      given: '#OperationObject'
      then:
        field: 'summary'
        function: 'truthy'
      severity: warn

I get an error:

Error running Spectral!
Error #1: Function is not defined
          at validateFunction  …tors/function.ts:27  return new RulesetV…
          at validate26        …ompile/index.ts:171  const makeValidate …
          at validate15        …ompile/index.ts:171  const makeValidate …
          at validate45        …ompile/index.ts:171  const makeValidate …
          at validate14        …ompile/index.ts:171  const makeValidate …

If I do this similar thing:

extends:
- "spectral:oas"
- "spectral:asyncapi"
aliases:
  OperationObject:
    - "#PathItem[get,put,post,delete,options,head,patch,trace]"
  PathItem:
    - $.paths[*]
rules:
  operation-summary:
    given: '#OperationObject'
    then:
      field: 'summary'
      function: 'truthy'
    severity: warn

Then it works.

Environment (remove any that are not applicable):

stoplight-bot commented 1 year ago

:tada: This issue has been resolved in version @stoplight/spectral-ruleset-migrator-v1.9.3 :tada:

The release is available on npm package (@latest dist-tag)

Your semantic-release bot :package::rocket:

stoplight-bot commented 1 year ago

:tada: This issue has been resolved in version 6.7.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: