redhat-developer / redhat-developer/vscode-yaml
yaml.schemas: document and support variable in schema paths
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 829
- Forks
- 260
- Avg merge
- 5h 43m
- Merged PRs (30d)
- 1
Description
Problem
The yaml.schemas setting requires absolute paths or URLs for local schema files. VS Code supports ${workspaceFolder} variable interpolation in many settings (e.g. launch.json, tasks.json, files.watcherExclude), but vscode-yaml does not resolve this variable. Users who work across machines (or share a committed .vscode/settings.json) must either hardcode an absolute path (breaks across machines) or use a schema registry URL (requires internet access).
Steps to Reproduce
- Create
.vscode/settings.json:{ "yaml.schemas": { "${workspaceFolder}/schemas/my-schema.json": "*.yaml" } } - Open a
.yamlfile in that workspace. - No schema validation occurs; the Output → YAML channel shows:
Unable to load schema from ${workspaceFolder}/schemas/my-schema.json
Expected Behaviour
The extension should resolve VS Code variable substitutions (${workspaceFolder}, ${workspaceFolder:name} for multi-root) before passing the schema URI to the language server. VS Code exposes these via vscode.workspace.workspaceFolders and the vscode.commands.executeCommand('vscode.resolveWorkspaceSetting') path.
Workaround
Users can use a relative path like ./schemas/my-schema.json, but this is neither documented nor consistently resolved across all YAML files in sub-directories.
Proposed Fix
In the configuration-reading code, after reading the yaml.schemas map keys, run each key through a variable resolver:
function resolveVars(schemaPath: string, folder: vscode.WorkspaceFolder): string {
return schemaPath.replace(/${workspaceFolder}/g, folder.uri.fsPath);
}
Document the supported variables in the extension README and the package.json setting description.
Environment
- OS: Windows 11 + macOS (affects both — different absolute paths per machine)
- VS Code: 1.89+, shared
.vscode/settings.jsonin git - Extension: redhat.vscode-yaml latest
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 in the configuration-reading code that handles yaml.schemas and trace how schema map keys are passed to the language server. Check the workspace variable APIs mentioned in the issue, then update the README and package.json setting description. Done means workspaceFolder and named multi-root variables resolve for local schema paths and the documented example validates successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100