Open mitar opened 2 years ago
Looking for this as well. I have a repository of schemas and documents using those schemas, except they're organized into file structures. This means whenever I go another folder deeper into my documents, I have to add a ../
to the $schema
and $ref
s in my document to reference the same local file. It would be nice to have all schemas in a workspace loaded to a list by their $id
s that you can auto-complete when you start typing in your domain name in a $ref
or $schema
.
I'm also looking for a simple solution for my JSON schemas to be resolved locally and I wanted to collect my findings.
It was suggested in a related issue (https://github.com/microsoft/vscode/issues/174672) to use the json.schemas
setting with the file://
protocol. However, I didn't manage to have VSCode load the correct schema when trying to reference a relative file since:
file://
protocol${workspaceFolder}
is not possible within schema references (https://github.com/microsoft/vscode/issues/166438)As a note, it is possible to use fileMatch
field but requires a specific path naming convention which is not always desired.
Resolving all schema by IDs as suggested by this issue would be the simplest! An alternative could be to go in the direction suggested by https://github.com/microsoft/vscode/issues/166438 and leverage the $ref
field within the json.schemas
configuration field.
{
"json.schemas": [
{
"url": "https://example.com/item.json",
"schema": {
"$ref": "file://${workspaceFolder}/schemas/items.json"
}
}
]
}
@aeschli I am hitting the same roadblock as the other commenters. Failed also with everything @njakob did.
Can we kindly ask to prioritize this work.
I have a JSON schema which looks like:
I would like that I would be able to edit them in VSCode with all
$ref
s resolving to their local counterparts. This can be done by VSCode parsing$id
field and determining the mapping from the remote URL to local file based on$id
.