Skip to content

Schema modeline ignores parent directory #1222

@saver-r

Description

@saver-r

Describe the bug

In a multi-root workspace, there's a schema

def/bla_schema.json

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "bla": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": ["foo", "bar", "fla"]
      }
    }
  },
  "required": ["bla"],
  "additionalProperties": false
}

In another project there's a file

use/bla.json

# yaml-language-server: $schema=def/bla_schema.json

bla:
  - foo
  - bar
  - fla
  - foo

Even though README says that paths are resolved wrt multi-project roots, validating just errors out.

Now trying a relative path over workspace roots:

# yaml-language-server: $schema=../def/bla_schema.json

Expected result

Path is resolved to <prefix>/use/../def/bla_schema.json and autocompletion is working.

Actual result

Path is resolved to <prefix>/use/def/bla_schema.json, thus yielding an invalid location. Obviously, autocompletion does not work.

Unable to load schema from '<prefix>/use/def/bla_schema.json': No content.YAML(768)

Proposed solution

Either

  1. support paths relative to workspace roots, or
  2. retain .. parts in modeline.

Environment

  • Windows
  • Mac
  • Linux (WSL2)
  • other (please specify)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions