microsoft / microsoft/vscode-json-languageservice

Consider also adding "propertyNames" to getMatchingSchemas

Open
#89 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request
Dominant language
TypeScript
Stars
326
Forks
145
Avg merge
22h 10m
Merged PRs (30d)
9

Description

I don't know if this was intentional or not, but schemas matching "propertyNames" are not added to matchingSchemas.

See https://github.com/microsoft/vscode-json-languageservice/blob/main/src/parser/jsonParser.ts#L946

For the extension I'm developing it would be nice to have propertyNames also included in matchingSchemas.

In my testing so far it seems fine to include propertyNames into matchingSchemas.

To explain my use case a bit more:

imagein you have the following json

{
  "definitions": {
    "foo": 1,
    "bar": 2
  },
  "reference": "foo"
}

I want to validate that the value of reference is consistent with the keys in definitions. So allowed values would be "foo" and "bar". This is obviously not possible with JsonSchema alone.

It would work if we would collect propertyNames in matchingSchemas and then iterate over matchingSchemas to find the properties and see if they are consistent with the reference.

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.

Research direction

Start in src/parser/jsonParser.ts around line 946, where schemas are added to matchingSchemas, and trace how propertyNames is handled. Include propertyNames in matchingSchemas and verify that the collected schemas support the described property-name use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
43/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.