opened
rob3c
username_0
Hi, please add support for environment variable replacements in JSON file schema properties.

Editing JSON files with vscode and the current schema support is great when using a relative path within a project or an absolute path when one is known. However, sometimes relative/absolute paths aren't possible. I believe there's already support for them in other JSON file contexts, but it doesn't look like the schema resolver is leveraging that code. (If it is, none of the syntax variations I've tried actually worked, and some of them crashed the JSON Language Server, requiring a restart.)
Add support for environment variable replacements in JSON schema URIs
issue
created
aeschli
username_1
@username_0 Can you please give an example of what you mean?
comment
created
rob3c
username_0
@username_1 Sure, thanks for looking into this!

Here's an example of how I might've expected it to work already like `${workspaceRoot}` does in _launch.json_:

`"$schema": "${workspaceRoot}/schemas/foo.schema.json",`


And here's how using an environment variable might look:

`"$schema": "${env:MY_SCHEMA_DIR_ENV_VAR}/foo.schema.json",`

I'm on Windows and originally tried this:

`"$schema": "%MY_ENV_VAR%/foo.schema.json"`

and this:

`"$schema": "file:///%MY_ENV_VAR%/foo.schema.json"`

which both reported:
```
The JSON Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted.
```
which forced me to restart vscode (escaping the percents didn't work either, of course). The percent notation is windows-specific anyway.
comment
created
DrecDroid
username_2
Hi, I see this feature useful. Right know to use a schema in a deeply nested json file one have to do something like:

    "$schema ": "../../../schemas/my_schema.json"

When would be easier to just write:

    "$schema": "${workspaceRoot}/schemas/my_schema.json"
comment
closed
aeschli
username_1
issue
created
aeschli
username_1
To keep the number of issues in our inbox on a manageable level, we're closing issues that have been on the backlog for a long time but haven't gained traction: We look at the number of votes the issue has received and the number of duplicates issues filed.
If you disagree and feel that this issue is crucial: We're happy to listen and to reconsider.
Maybe you want to give it a try yourself and provide the feature through an extension or a PR: We're happy to give advise and get you started.
Thanks for your understanding. Thanks for helping and happy coding!
comment