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

Keys requiring quotation can bork the schema #439

Closed
1 of 4 tasks
phlax opened this issue Feb 24, 2021 · 2 comments · Fixed by redhat-developer/yaml-language-server#435
Closed
1 of 4 tasks

Keys requiring quotation can bork the schema #439

phlax opened this issue Feb 24, 2021 · 2 comments · Fixed by redhat-developer/yaml-language-server#435
Assignees
Milestone

Comments

@phlax
Copy link

phlax commented Feb 24, 2021

Describe the bug

(Related to #438 )

I have a schema in which there are conditional extensions based on the value of a property.

If that property starts with @ and therefore requires to be quoted, autocomplete can bork the schema (or at least further autocompletion")

For example, given the following schema:

{
    "type": "object",
    "properties": {
        "typed_config": {
            "type": "object",
            "allOf": [
                {
                    "properties": {
                        "@type": {
                            "type": "string",
                            "enum": [
                                "type1.schema",
                                "type2.schema"
                            ]
                        }
                    }
                },
                {"oneOf": [
                    {
                        "if": {
                            "properties": {
                                "@type": { "const": "type1.schema"}
                            }
                        },
                        "then": {
                            "properties": {
                                "extra1": {
                                    "type": "string"
                                }
                            }
                        },
                        "else": {"not": {}}
                    },
                    {
                        "if": {
                            "properties": {
                                "@type": { "const": "type2.schema"}
                            }
                        },
                        "then": {
                            "properties": {
                                "extra2": {
                                    "type": "string"
                                }
                            }
                        },
                        "else": {"not": {}}
                    }
                ]}
            ]
        }
    }
}

If the user uses autocomplete to add the @type property, the enumerated values are not shown.

If the user then goes back and adds the necessary " around the key, then the enumerated values are shown, but the autocomplete then borks

borked-enumeration-autocomplete

If the user adds the full "@type" from the outset - ie doesnt use autocomplete, then it works as expected

not-borked-autocomplete

Expected Behavior

handle keys starting with @ better/more consistently

Current Behavior

using autocomplete to fill key starting with @ borks further autocompletion

Steps to Reproduce

see above

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)
@phlax
Copy link
Author

phlax commented Feb 24, 2021

i think the easiest fix might be if autocomplete knows that a key requires quotation, it adds it automatically - afaict the yaml spec allows quoted keys, so i guess they should be supported

not sure what qualifies as requiring quotation but i would guess if the string contains anything non alphanumeric

@phlax
Copy link
Author

phlax commented Apr 8, 2021

thanks @evidolob that is v helpful!!!

bleach31 pushed a commit to bleach31/vscode-yaml that referenced this issue Jan 25, 2022
* redhat-developer#439 add telemetry notification

Signed-off-by: Yevhen Vydolob <yvydolob@redhat.com>

* Update src/languageserver/telemetry.ts

Co-authored-by: Josh Pinkney <jpinkney@redhat.com>

* Fix review comments

Signed-off-by: Yevhen Vydolob <yvydolob@redhat.com>

* reorder fields

Signed-off-by: Yevhen Vydolob <yvydolob@redhat.com>

* add test

Signed-off-by: Yevhen Vydolob <yvydolob@redhat.com>

Co-authored-by: Josh Pinkney <jpinkney@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants