redhat-developer / redhat-developer/vscode-yaml
Schema modeline should also resolve schema path from project root or multi-project root
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 829
- Forks
- 260
- Avg merge
- 5h 43m
- Merged PRs (30d)
- 1
Description
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
- support paths relative to workspace roots, or
- retain
..parts in modeline.
Environment
- Windows
- Mac
- Linux (WSL2)
- other (please specify)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the README's documented path-resolution behavior and trace the schema modeline handling used for multi-root workspaces. Reproduce the provided def/bla_schema.json and use/bla.json layout, then verify that validation and autocompletion resolve both root-relative and .. paths to the intended schema.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vscode
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100