sublimelsp / LSP-json

Schema validation/completions for your JSON and Sublime files
MIT License
72 stars 9 forks source link

How do I point to a schema stored locally in the project? #148

Closed SyntaxColoring closed 7 months ago

SyntaxColoring commented 1 year ago

I want a file to be checked with a schema that's stored locally in the project.

I tried this:

"userSchemas": [
    {
        "fileMatch": ["path/to/files/*.json"],
        "uri": "./project_relative/path/to/schema.json"
    }
]

But this gives me an error unable to load schema from '/./project_relative/path/to/schema.json'`.

I also tried this:

"userSchemas": [
    {
        "fileMatch": ["path/to/files/*.json"],
        "uri": "$project_path/project_relative/path/to/schema.json"
    }
]

But it doesn't look like $project_path gets expanded. This gives me an error unable to load schema from '/$project_path/project_relative/path/to/schema.json'`.

Is this possible?

rchl commented 1 year ago

Relative paths are not currently supported. The value needs to be an URI so in a format like file:///Users/... which means it can't be relative.

rchl commented 1 year ago

If it's an option to modify the JSON file then those can include a $schema property that points to a schema.

EDIT: Well, but in that case it would still have to be an URI...

jwortmann commented 1 year ago

Relative paths for the $schema property within the JSON file work fine on my side...