Skip to content

Enum strings YES / NO are converted to boolean incorrectly #1036

@jeremyfiel

Description

@jeremyfiel

Describe the bug

In the following schema, the enum has two string values, YES and NO. These values are converted into a boolean because these two values are equivalent replacements in prior versions of YAML. I want to use them as string values in my data instance.

$schema: http://json-schema.org/draft-04/schema#
type: object
additionalProperties: false
required:
  - test
properties:
  test:
    type: string
    enum:
      - 'YES'
      - 'NO'
      - JEREMY
# yaml-language-server: $schema=test.schema.yaml
test: YES

Image

Image

Expected Behavior

The string values should be preserved and not converted to boolean per the 1.2 Specification.

The primary objective of this revision is to bring YAML into compliance with JSON as an official subset. YAML 1.2 is compatible with 1.1 for most practical applications - this is a minor revision. An expected source of incompatibility with prior versions of YAML, especially the syck implementation, is the change in implicit typing rules. We have removed unique implicit typing rules and have updated these rules to align them with JSON's productions. In this version of YAML, boolean values may be serialized as “true” or “false”;

Current Behavior

The string values are converted to boolean, incorrectly.

Steps to Reproduce

  1. create the schema
  2. create the test file and add the modeline to assign the schema
  3. use auto-suggestion to display enum values
  4. select YES or NO
  5. observe value is converted to boolean

Environment

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

Metadata

Metadata

Labels

Type

No type

Projects

Status

✅ Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions