stoplightio / vscode-spectral

VS Code extension bringing the awesome Spectral JSON/YAML linter with OpenAPI/AsyncAPI support
https://marketplace.visualstudio.com/items?itemName=stoplight.spectral
Apache License 2.0
72 stars 23 forks source link

documentationUrl causes #235

Open tomereli opened 6 months ago

tomereli commented 6 months ago

For support questions, please use the Stoplight Community Forum. This repository's issues are reserved for feature requests and bug reports. If you are unsure if you are experiencing a bug, the Community Forum 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 When adding documentationUrl to the custom spectral ruleset file, the extension breaks with error, although documentationUrl is a valid supported configuration according to https://docs.stoplight.io/docs/spectral/e5b9616d6d50c-rulesets#documentation-url

To Reproduce

Enable the extension with the following .spectral.yaml:

extends: 
  - "spectral:oas"
rules:
  # ---------------------------------------------------------------------------
  # @description: verify x-visibility is available for every operation
  # @link: https://go/apis-security-lint/x-visibility
  # ---------------------------------------------------------------------------
  x-visibility-truthy:
    documentationUrl: https://go/apis-security-lint/x-visibility
    description: x-visibility check
    message: "Make sure x-visibility is available for every operation"
    severity: "error"
    given: "$.paths.*.*"
    then:
      field: x-visibility
      function: truthy

You should see the error in the Spectral OUTPUT log.

Now remove the documentationUrl and the error is gone.

Expected behavior When documentationUrl is set in a rule, the extension should not break, and when hovering over a warning or an error with a documentationUrl link, it should provide a clickable link to the URL defined in the .spectral.yaml file.

Screenshots .spectral.yaml with documentationUrl (note that the openapi.json is not red - this is cause the extension broke):

image

Same .spectral.yaml without it (note that the extension output is fine, and the openapi.json file is red):

image

Environment:

Additional context Add any other context about the problem here.

ouvreboite commented 3 months ago

Is the error still happening for you?

I'm working on adding support for documentationUrl (i.e. "click on error'scode to open the documentation site"), and I did not encoutered any runtime bug.