Skip to content

Array with default and required values are not rendered correctly #1187

@rH4rtinger

Description

@rH4rtinger

Describe the bug

I have used the below schema. This schema has a property (foo) that is required, an array and have default values.

When I am in a new file that uses this schema and press Ctrl + Space to see every required property for my schema, I only see ${1} for my array:

Image

When I press Tab to get this schema, I only get hello (the default value for my string property) in the spaces of the array.

This would therefore require any user of my schema to notice that the default value is completly wrong and then manuelly correct them.

The property foo in the below Schema exists in multiple ways, because I tested if one of them works (none work).

The normal way how I use default values with arrays is foo-two-default.

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "properties": {
    "bar": {
      "type": "string",
      "default": "hello"
    },
    "num": {
      "type": "number",
      "default": "42"
    },
    "foo-two-default": {
      "type": "array",
      "default": [
        "foo-two-default"
      ],
      "items": {
        "type": "string",
        "default": "foo-two-default"
      }
    },
    "foo-default-in-items": {
      "type": "array",
      "items": {
        "type": "string",
        "default": "foo-default-in-items"
      }
    },
    "foo-default-outside": {
      "type": "array",
      "default": [
        "foo-default-outside"
      ],
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "foo-two-default",
    "foo-default-in-items",
    "foo-default-outside",
    "bar",
    "num"
  ],
  "title": "dummy"
}

Expected Behavior

I would expect that my array default values will be given normally as normal string or number properties are.

Current Behavior

  • In the preview, some placeholder values ${1} are visible
  • In the inital creation of the yaml document, the default value of my string value will be used.
  • When deleting the wrong default value and pressing CTRL + Space, the correct default values are found and rendered (OK)

Steps to Reproduce

  1. Use above schema in VS Code for any file
  2. In the file: Press Ctrl + Space and see the preview
  3. Use the preview to create the YAML content

Image

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions