Skip to content

Nested object validation error #168

Open
@gabriel-turturica

Description

@gabriel-turturica

file schema.json

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "dataType": { "$ref": "#/$defs/datatypes-enum" }
  },
  "required": ["dataType"],
  "$defs": {
    "datatypes-enum": {
      "oneOf": [
        {
          "type": "string",
          "enum": ["bool", "boolA"]
        },
        {
          "type": "object",
          "patternProperties": {
            "^[a-zA-Z0-9_]+$": { "$ref": "#/$defs/datatypes-enum" }
          }
        }
      ]
    }
  }
}

file data.json

{
  "dataType": { "test": { "test": { "test": "bool" } } }
}

Expected results when validating data.json against schema.json: valid file (verified using https://www.jsonschemavalidator.net/ and jsonschema in python).
Results I get: "schema with # /$defs/datatypes-enum/oneOf/0 already inserted".

Any advice would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions