Vscode-yaml: Support for local schemas / schema check

Created on 11 Apr 2018  路  7Comments  路  Source: redhat-developer/vscode-yaml

Hi, I'm starting to use the plugin and there are two questions that come to mind:

  • Is there a way to use a local schema that isn't available through a URL? We're using a custom yaml-based format and we'd like to use its schema without the requirement of having it uploaded somewhere. If it is not currently possible, I'd like to submit that feature as a potential enhacenment.

  • As a followup, is there any way to confirm that the schema defined through user settings is currently loaded? If not, it would be nice to have feedback regarding whether the file has been found, and/or if it's accepted as a valid schema.

Thanks!

question

Most helpful comment

I was able to get absolute paths working by using the file:// URI syntax for local files.

For example, this sort of thing didn't work:

"yaml.schemas": {
    "/Users/dwtkns/my-yaml-schema.json": "/my-yaml.yml"
}

...but this did:

"yaml.schemas": {
    "file:///Users/dwtkns/my-yaml-schema.json": "/my-yaml.yml"
}

All 7 comments

I believe using a relative path works but using an absolute path doesn't work.

I've tried with these and they don't work

"yaml.schemas": {
        "~/Documents/work/untitled/src/composer.json": "/*"
}

"yaml.schemas": {
        "/home/jpinkney/Documents/work/untitled/src/composer.json": "/*"
}

But these works fine for me

"yaml.schemas": {
        "./composer.json": "/*"
}

"yaml.schemas": {
        "../composer.json": "/*"
}

If you're looking to contribute absolute paths for schemas you might want to look around this area

As a followup, is there any way to confirm that the schema defined through user settings is currently loaded? If not, it would be nice to have feedback regarding whether the file has been found, and/or if it's accepted as a valid schema.

I've added that as of this. It will be added Monday when we do a release.

But these works fine for me

"yaml.schemas": {
"./composer.json": "/*"
}

"yaml.schemas": {
"../composer.json": "/*"
}
```
If you're looking to contribute absolute paths for schemas you might want to look around this area

Sorry for a stupid question, @JPinkney, but the above paths are relative to which folder? .vscode or something else?

I believe its relative to the root of the project

I believe its relative to the root of the project

Yeah, it works! Thanks a lot!

I think this bug should be reopened until we get some documentation around how to configure local paths.

I was able to get absolute paths working by using the file:// URI syntax for local files.

For example, this sort of thing didn't work:

"yaml.schemas": {
    "/Users/dwtkns/my-yaml-schema.json": "/my-yaml.yml"
}

...but this did:

"yaml.schemas": {
    "file:///Users/dwtkns/my-yaml-schema.json": "/my-yaml.yml"
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

joshuaavalon picture joshuaavalon  路  4Comments

hppsc1215 picture hppsc1215  路  7Comments

gauthamp10 picture gauthamp10  路  5Comments

miqm picture miqm  路  4Comments

rylnd picture rylnd  路  3Comments