How to: $ref to external schemas in VSC

Open
#207 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
json, typescript, vscode

Research direction

No files, tests, or entry points are named. Start by tracing how the JSON language service registers schemas and resolves external $ref URLs, then verify whether IntelliSense exposes properties from anotherNestedSchema.json in the shown instance.

Written by the indexing model from the issue text.

Description

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). 
Dominant language
TypeScript
Stars
326
Forks
145
Avg merge
22h 10m
Merged PRs (30d)
9

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/vscode-json-languageservice

All issues in microsoft/vscode-json-languageservice

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.