vscode-yaml
vscode-yaml copied to clipboard
Property shows up multiple times in completions
Describe the bug
If a schema uses anyOf
and multiple objects have a property with the same name, but different sets of required fields, then that property shows up twice in auto completion (see example schema below).
Expected Behavior
In the below example, spec
should only show in completions once.
Current Behavior
The spec
field is shown in completions twice
Steps to Reproduce
1.Create the below schema 2. Reference it in a yaml file 3. Start auto completion at the first character in the file
If you remove the required
section in the second object, then completion correctly shows only one spec
completion.
{
"$schema": "http://json-schema.org/draft-07/schema",
"oneOf": [
{
"type": "object",
"properties": {
"spec": {
"type": "object"
}
}
},
{
"properties": {
"spec": {
"type": "object",
"required": [
"bar"
],
"properties": {
"bar": {
"type": "string"
}
}
}
}
}
]
}
Environment
- [X] Windows
- [ ] Mac
- [ ] Linux
- [ ] other (please specify)
@afscrome Here oneOf contains two properties and both name is spec.
- spec of object type
- spec of object with child property bar
So we can suggest user that all matching properties and used can pick the opt one
In the VS Code JSON editor, this same schema only shows a single spec
property
So to does Rider
The wider context in which I encountered this I'm trying to use Backstage's object schema for it's catalog-info.yaml
files. (This schema is heavily inspired by Kubenetes object format)
- json schema - https://json.schemastore.org/catalog-info.json
- docs - https://backstage.io/docs/features/software-catalog/descriptor-format, with a schema
If using this schema in the VS Code JSON editor or Rider, the the auto completions come out as expected, and are easy to use, with no duplicate property names
But when I use this same schema with the VS Code YAML extension , the auto completions become overwhelming with duplicates, duplicated, to the point of not being very useful. There are quite a few issues which I suspect are related, but I'm still trying to reduce them to a minimal repo
@afscrome Let me check and get back to you ASAP