Skip to content

Support for propertyNames schema is incorrect #1141

@glopesdev

Description

@glopesdev

Describe the bug

Support for the propertyNames keyword seems to have been introduced in #720.

However, it seems the actual implementation is only providing the title of the propertyNames schema as completion, rather than the schema enum values themselves.

This most likely means the suggested completion will be an invalid value, as more often than not the name of the schema is not itself an actual permitted value.

Example Schema

schema.json

{
  "$defs": {
    "EventName": {
      "enum": [
        "None",
        "Event1",
        "Event2"
      ],
      "title": "EventName",
      "type": "string"
    }
  },
  "properties": {
    "events": {
      "additionalProperties": {
        "type": "integer"
      },
      "propertyNames": {
        "$ref": "#/$defs/EventName"
      },
      "title": "Events",
      "type": "object"
    }
  },
  "required": [
    "events"
  ],
  "title": "FooContainer",
  "type": "object"
}

Expected Behavior

Given the above schema with propertyNames, provide as completion the list of valid property names.

Image

Current Behavior

Only the name of the schema definition is offered as completion:

Image

Steps to Reproduce

  1. Save the schema schema.json into a local file.
  2. Create a new YAML file, e.g. config.yaml
  3. Declare schema.json as the inline schema for the yaml language server:
# yaml-language-server: $schema=schema.json
  1. Ask for a completion when hovering over the space where typing dictionary keys.

Environment

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions