Theia: JSON preferences do not support relative paths for schema associations

Created on 12 Feb 2020  路  3Comments  路  Source: eclipse-theia/theia

Description

In JSON preferences, the definition of json.schemas : url says it accepts a relative path to a schema in the current directory.
(https://github.com/eclipse-theia/theia/blob/master/packages/json/src/browser/json-preferences.ts)

When using a relative path the following error occurs:
[json] Unable to load schema from '/.schemas/my-schema-definition.json': ENOENT: no such file or directory, open '/.schemas/my-schema-definition.json'.

Using the absolute path to this schema works though.

Reproduction Steps

  • Run theia example (browser or electron)
  • Define a schema association for a JSON file and a JSON schema in the runtime workspace by using a relative path (see also screenshot).

theia-json-issue

OS and Theia version:
OS: Ubuntu 18.04
Theia: 3468d003

Diagnostics:

bug help wanted json

All 3 comments

Hi!
I took a look into this and have created a proposal to fix this issue (but did not open a PR yet).
(also see https://github.com/ndoschek/theia/tree/fix7140)

Anyhow, I came across a minor problem, namely the jsonSchemaService (vscode-json-languageservice) returns the following warning:
Problems loading reference 'file:///test/my-schema-definition.json': Unable to load schema from '/test/my-schema-definition.json': ENOENT: no such file or directory, open '/test/my-schema-definition.json'.

The JSON schema support works as expected now also for relative paths, but this warning occurs.
Do you have an idea how to overcome this problem or is it okay to open a PR with my proposed fix?

Thank you in advance for your answer.

@ndoschek please open a PR, it would be easier to see and try changes

It's fixed on master.

Was this page helpful?
0 / 5 - 0 ratings