microsoft / microsoft/vscode-json-languageservice
code completion breaks when anyOf defines `required` properties.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 326
- Forks
- 145
- Avg merge
- 22h 10m
- Merged PRs (30d)
- 9
Description
#204 describes an issue with anyOf (and oneOf) error messaging. However, one way to solve this is to provide a schema-specific error message using the custom JSON property errorMessage as illustrated in this example.
However, the use of the required property (or the dependencies property) on anyOf subschemas will prevent monaco from surfacing it as a valid suggestion. In my example above, p1.shape can be fulfilled by both rectangle and square. However, the only autocomplete option that gets offered is rectangle
The reason this occurs is because the square subschema defines a required field side that is only available within that schema. It essentially ends up making square a hidden option for p1.shape critically breaking the expected completion.
PS: If side were to be removed from the required array in L62 of the example, completions start working as expected.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the linked Monaco examples and inspecting the completion handling for anyOf subschemas with required or dependencies. Done means autocomplete offers both rectangle and square for p1.shape while preserving the expected behavior when side is required.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100