sublimelsp / LSP-json

Schema validation/completions for your JSON and Sublime files
MIT License
72 stars 9 forks source link

Add support for `$ref` accross sublime:// schemes #141

Closed deathaxe closed 1 year ago

deathaxe commented 1 year ago

This commit enables a $ref in a package provided scheme A to point to a definition in schema B.

The given uri sublime://package/schemas/schema2/definitions/myObject needs to be resolved and return the serialized JSON object the uri points to. In the given example it is schema2_content['definitions']['myObject'].

Example:

{
  "contributions": {
    "settings": [
      {
        "file_patterns": [],
        "schema": {
          "$id": "sublime://package/schemas/schema1",
          "type": "object",
          "properties": {
            "$ref": "sublime://package/schemas/schema2/definitions/myObject"
          }
        }
      },
      {
        "file_patterns": [],
        "schema": {
          "$id": "sublime://package/schemas/schema2",
          "type": "object",
          "definitions": {
            "myObject": {
              "type": "object",
              "description": "A globally used object."
            }
          }
        }
      }
    ]
  }
}