redhat-developer / redhat-developer/vscode-yaml
Default value from subschema used for string autocompletion elsewhere
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 829
- Forks
- 260
- Avg merge
- 5h 43m
- Merged PRs (30d)
- 1
Description
Describe the bug
The default value of a property in one subschema is unintentionally used as default value in string item property.
I have a json schema like so:
{
"$defs": {
"Foo": {
"properties": {
"foo": {
"type": "string",
"default": "hello"
}
},
"type": "object"
}
},
"additionalProperties": false,
"properties": {
"foos": {
"items": {
"$ref": "#/$defs/Foo"
},
"type": "array"
},
"bars": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"bars",
"foos"
],
"type": "object"
}
The completions for this schema is shown like this:
correctly showing the default value for foo but also showing ${1} for bar. When hitting enter, the default value is applied to the bar element as well:
Expected Behavior
I expect the default value to only show up for the property it is defined for.
Current Behavior
Default value shows up unexpectedly in wrong place.
Steps to Reproduce
- Copy the schema
- ctrl + space in new file which uses the schema
- hit enter
Environment
- Windows
- Mac
- Linux
- other (please specify)
Contributor guide
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
Reproduce the issue in VS Code using the provided schema: trigger completion in a new file and compare the foos and bars array items. Trace the completion path for JSON Schema defaults, then verify that hello is offered only for foo and is not inserted for bar.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json, typescript, vscode
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100