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
69 stars 23 forks source link

✨ Clicking on a rule's code in the tooltip open the rule's documentationUrl in the browser #237

Open ouvreboite opened 2 months ago

ouvreboite commented 2 months ago

Fixes #235

Allow to "click to know more" on a problem's rule code, using the rule/ruleset documentationUrl.

This allow the user to access a richer documentation and to not be restricted to just the error message/error code.

Checklist

Does this PR introduce a breaking change?

image image

The error-code becomes clickable (in the Problems view but also in the tooltip).

The link is constructed following the rules defined here:

Additional context

🚨This feature requires Diagnostic.codeDescription, with is available in https://www.npmjs.com/package/vscode-languageserver-types > 3.16, which required upgrading some other vscode-languageserver and client dependencies.

I'm using a basic ruleset to test it locally, but I've not pushed it:

formats: ["oas3"]
documentationUrl: https://example.com
extends: spectral:oas
rules:
  with-direct-documentation: #should have the doc https://example.com/direct
    documentationUrl: https://example.com/direct
    severity: error
    given: $.tags[*]
    then:
      field: description
      function: falsy
  without-direct-documentation: #should have the doc https://example.com#without-direct-documentation
    severity: error
    given: $.tags[*]
    then:
      field: description
      function: truthy