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

Default value from subschema used for string autocompletion elsewhere #1076

Open
1 of 4 tasks
wkrill opened this issue Dec 27, 2024 · 0 comments
Open
1 of 4 tasks

Default value from subschema used for string autocompletion elsewhere #1076

wkrill opened this issue Dec 27, 2024 · 0 comments

Comments

@wkrill
Copy link

wkrill commented Dec 27, 2024

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:
Image
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:
Image

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

  1. Copy the schema
  2. ctrl + space in new file which uses the schema
  3. hit enter

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)
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

1 participant