Skip to content

Invalid validation with oneOf and const #208

@joshuaavalon

Description

@joshuaavalon

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.

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