Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There should be a way to specify Schema file that is part of the project #123

Open
lashchev opened this issue Sep 27, 2018 · 6 comments
Open

Comments

@lashchev
Copy link

During active development, especially for a small or local or private project there is no justification to post schema to some hosted location, like Schema store.

yaml.schemas settings should allow specifying ${workspaceFolder} placeholder in file:///local-path or, ideally, just recognize relative path notation

For example: /schemas/my-schema.json should mean that schema file is located in file:///${workspaceFolder}/schemas/my-schema.json

The only way it works right now is if we specify absolute path of the schema file on local file system in Worspace settings file, but it doesn't work in generall, because different developers / dev boxes have different folder names/structure.

VSCode-yaml extension v0.0.16
VSCode: (windows portable install)
Version: 1.27.2
Commit: f46c4c469d6e6d8c46f268d1553c5dc4b475840f
Date: 2018-09-12T16:17:45.060Z
Electron: 2.0.7
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64

@JPinkney
Copy link
Contributor

If i'm not mistaken you can do something like:

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

So that "./schemas/my-schema.json is applied to my.schema.yaml.

Relative paths should work.

@lashchev
Copy link
Author

lashchev commented Oct 9, 2018

@JPinkney Your example indeed works, but only in single-folder workspace (at least we couldn't make it work in muulti-root workpsace). Is there any trick on how to make it work in multi-folder workspace?

If feels like it be better to support standard VSCode reference variables as in https://code.visualstudio.com/docs/editor/variables-reference

Could you please clarify what do you mean by relative paths? Relative to what?

Also, we need a way to specify that schema location is relative to the YAML file. The simplified folder structure of our data is like this:

\dataSet1\data\my.yaml
\dataSet1\schemas\mySchema.json
\dataSet2\data\my.yaml
\dataSet2\schemas\mySchema.json

So, we would like to specify something like this in yaml.schemas:

"my.yaml": "../schemas/mySchema.json"

Currently, ../schemas will point to the folder one level above of the project folder.

@JPinkney JPinkney added this to the 0.5.0 milestone Mar 12, 2019
@boopathi
Copy link

I'd like to use

  • ~/schemas/mySchema.json
  • $HOME/schemas/mySchema.json

where some schemas are shared between multiple projects.

@jmigual
Copy link

jmigual commented Mar 19, 2024

I was trying to get something like:

# yaml-language-server: ${workspaceFolder}/my-schema.json

But it didn't seem to work. Would this be possible?

@ptr727
Copy link

ptr727 commented May 29, 2024

Yes please, setting schema sets an absolute path that works on just that system not any system.

@ChristopherJTrent
Copy link

ChristopherJTrent commented Sep 17, 2024

If i'm not mistaken you can do something like:

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

So that "./schemas/my-schema.json is applied to my.schema.yaml.

Relative paths should work.

this appears to have been removed in favor of the rather frustratingly unhelpful error message "unable to load schema from '/<whatever path you specified>': No Content."
Would it be possible to either have the marketplace description updated to note what is meant by

"It is possible to specify a yaml schema using a modeline. Schema url can be a relative path. If a relative path is specified, it is calculated from yaml file path, not from workspace root path"

or have the extension updated to use a more user-friendly path resolution method?

EDIT: It turns out I was incorrect on this. I just encountered a bit of a footgun created by a mismatch between the marketplace description and the README. Reading the README here gives the correct information, while the information in the vscode marketplace appears to be outdated. Definitely would be happy to see an update to the marketplace page to bring it in line with the README here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants