microsoft / vscode-json-languageservice

JSON language service extracted from VSCode to be reused, e.g in the Monaco editor.
Other
261 stars 110 forks source link

How to: $ref to external schemas in VSC #207

Open jeremyfiel opened 1 year ago

jeremyfiel commented 1 year ago

Where would one register referenced schemas in VSC so they would be available to Intellisense?

I have a schema with multiple (possibly hundreds) of subschemas which I want to write a data instance against. How can I use VSC Intellisense to guide me through the schema while I'm creating an instance?

Take this concocted example:

{
    "id": "http://example.com/common/mainSchema.json",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "allOf": [
        {
            "type": "object",
            "properties": {
                "id": {
                    "$ref": "simpleIDType_v01.json#"
                }
            }
        },
        {
            "$ref": "anotherNestedSchema.json#"
        }
    ]
}
{
    "id": "http://example.com/common/simpleIDType_v01.json",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "string",
    "pattern": "^[a-zA-Z0-9]+$"
}
{
    "id": "http://example.com/common/anotherNestedSchema.json",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "properties": {
        "organizationId": {
            "$ref": "simpleIDType_v01.json#"
        }
    }
}
#instance 
{
"$schema": "http://example.com/common/mainSchema.json",
"id": "testing",
"   <<  I want Intellisense to provide the available properties in the `allOf/1` subschema (anotherNestedSchema).