Ability to specify schema as a comment in the YAML file
See original GitHub issueIs your enhancement related to a problem? Please describe.
A common problem with this extension is mis-detection of the correct schema. For example, a file named deploy.yml
is assumed to be a PHPDeployer file because this is the only match on JSON Schema Store.
Related issues:
The only way to override an incorrect schema is to set glob to schema mapping in the VS Code settings, but this means the settings can’t easily be shared between developers or committed to version control.
Describe the solution you would like
It should be possible to insert a leading comment in a YAML file that declares its schema.
VS Code natively supports this for JSON files via a VS Code-specific $schema
property (because JSON doesn’t support comments):
{
"$schema": "http://json-schema.org/draft-04/schema#",
...
}
In a YAML file, a comment could be used:
# $schema: https://json.schemastore.org/github-workflow
name: Foo
When this comment is present, this extension should skip fetching schemas from Schema Store and fetch the linked schema directly, if necessary.
Describe alternatives you have considered
I have no considered whether any other editors or IDEs support such a syntax for YAML file schema declaration. If they do, it would be worth trying to be compatible.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:15
- Comments:6 (1 by maintainers)
Top GitHub Comments
I think yes, it could. As for #397 we have draft PR to fix schema selection https://github.com/redhat-developer/yaml-language-server/pull/362
Any PR is welcome.
@johnbillion yaml-language-server already supports this Maybe we just need to add description in to vscode-yaml extension readme.