Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property shows up multiple times in completions #829

Closed
1 of 4 tasks
afscrome opened this issue Sep 22, 2022 · 3 comments
Closed
1 of 4 tasks

Property shows up multiple times in completions #829

afscrome opened this issue Sep 22, 2022 · 3 comments
Milestone

Comments

@afscrome
Copy link

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.
image

Current Behavior

The spec field is shown in completions twice
image

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

  • Windows
  • Mac
  • Linux
  • other (please specify)
@msivasubramaniaan
Copy link
Contributor

@afscrome Here oneOf contains two properties and both name is spec.

  1. spec of object type
  2. spec of object with child property bar

So we can suggest user that all matching properties and used can pick the opt one

@afscrome
Copy link
Author

In the VS Code JSON editor, this same schema only shows a single spec property
image
So to does Rider
image

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)

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
image
image

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

image
image

@msivasubramaniaan
Copy link
Contributor

@afscrome Let me check and get back to you ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants