Skip to content

How to get $refs working? #743

@OnkelTem

Description

@OnkelTem

I read the documentation but couldn't find anything about using $refs and how they get resolved.

Consider the following definitions:

foo.schema.json

{
  "$id": "https://someprefix/foo",
  "title": "Foo",
  "type": "object",
  "properties": {
    "bar": { "$ref": "bar#" }
  },
  "required": ["bar"]
}

bar.schema.json

{
  "$id": "https://someprefix/bar",
  "title": "Bar",
  "type": "object",
  "properties": {
    "value": { "type": "string" }
  },
  "required": ["value"]
}

As you see the https://someprefix/foo schema depends on the https://someprefix/bar one. The reference to from foo to bar is performed via { "$ref": "bar#" }. Unfortunately it doesn't work with this plugin:

# yaml-language-server: $schema=./foo.schema.json
bar:
  value: "hello"

results to a validation error:

Problems loading reference 'file:///projects/bar': Unable to load schema from '/projects/bar': No content.YAML(768)

Is there a way to load all the schemas from a directory to get this resolution working? This is how Ajv resolution works for example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions