Vscode-yaml: Invalid validation with oneOf and const

Created on 28 Jul 2019  路  4Comments  路  Source: redhat-developer/vscode-yaml

Data

VSCode Setting

{
  "yaml.schemas": {
    "test.schema.json": "test.yaml"
  }
}

Schema

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://example.com/test.schema.json",
  "title": "Test",
  "description": "Bug Test",
  "type": "object",
  "properties": {
    "tag": {
      "$ref": "#/definitions/tags"
    }
  },
  "definitions": {
    "tag": {
      "type": "object",
      "properties": {
        "category": {
          "type": "string",
          "enum": ["A", "B"]
        },
        "name": {
          "oneOf": [
            { "title": "T1", "const": "T1" },
            { "title": "T2", "const": "T2" },
            { "title": "T3", "const": "T3" }
          ]
        }
      },
      "additionalProperties": false,
      "required": ["category", "name"]
    },
    "tags": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/tag"
      },
      "uniqueItems": true
    }
  }
}

YAML

tag:
  - category: A
    name: T1

Expected

No Error

Result

I get the following error on name.

Matches multiple schemas when only one must validate.

Most helpful comment

This is actually because the current version released on the marketplace doesn't support JSON Schema 6 or 7 (I believe const was from JSON Schema 6) . When testing it out on the newest version of the YAML language server it doesn't throw any errors.

The version supporting JSON Schema 7 should be released within a couple weeks.

All 4 comments

This is actually because the current version released on the marketplace doesn't support JSON Schema 6 or 7 (I believe const was from JSON Schema 6) . When testing it out on the newest version of the YAML language server it doesn't throw any errors.

The version supporting JSON Schema 7 should be released within a couple weeks.

Any updates on releases with support for Schema 7

I was initially confused because the ReadMe at the root level lists support for Schema 7 since May 27, but then realized that releases might not be on the latest version.

In either case, thanks for the awesome tool, and I appreciate any support time you have! :)

@KyleMit It should all be working with our latest release (0.5.x). I've just double checked with the above example and everything is working. If you come across any other json schema 7 issues please file a bug report!

Ok, great, thanks for the added clarity! I was noticing some issues so I'll document test cases for them in another thread

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rylnd picture rylnd  路  3Comments

Chagrilled picture Chagrilled  路  4Comments

tracker1 picture tracker1  路  5Comments

riker09 picture riker09  路  5Comments

nicholas-devlin picture nicholas-devlin  路  4Comments