Skip to content

Ability to specify schema as a comment in the YAML file #401

@johnbillion

Description

@johnbillion

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.

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