question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to specify schema as a comment in the YAML file

See original GitHub issue

Is 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:open
  • Created 3 years ago
  • Reactions:15
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
evidolobcommented, Nov 27, 2020

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.

1reaction
evidolobcommented, Nov 27, 2020

@johnbillion yaml-language-server already supports this Maybe we just need to add description in to vscode-yaml extension readme.

Read more comments on GitHub >

github_iconTop Results From Across the Web

YAML - Comments - Tutorialspoint
The shortcut key combination for commenting YAML blocks is Ctrl+Q. Select the block. Use “CTRL + /” on Linux and Windows and “CMD+/”...
Read more >
How do you do block comments in YAML? - Stack Overflow
Open file in editor Select the block and press Ctrl + forward slash , you will have selected block starting with #. Now...
Read more >
YAML Schema Files - Doctrine1
Doctrine offers the ability to specify a detect_relations option as you saw earlier. This feature provides automatic relationship building based on column names ......
Read more >
How to configure YAML schema to make editing files easier
To benefit from the JSON Schema store and the built-in integration offered by IDEs, the YAML schema writer needs to set a file...
Read more >
How to create your own auto-completion for JSON and YAML ...
Depending on the complexity of the file whose schema you are creating, it can be a little boring to specify every available option,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found