Skip to content

V2019-09 not validating field type under properties #313

@arandjel

Description

@arandjel

Hi,

First of all, this is really nice library, thanks for it.

I've discovered issue where V2019-09 is not validating json properly. Schema that I've tried using for validating json is:

{
    "$schema": "https://json-schema.org/draft/2019-09/schema",
    "$id": "https://json-schema.org/draft/2019-09/schema",
    "$vocabulary": {
        "https://json-schema.org/draft/2019-09/vocab/core": true,
        "https://json-schema.org/draft/2019-09/vocab/applicator": true,
        "https://json-schema.org/draft/2019-09/vocab/validation": true,
        "https://json-schema.org/draft/2019-09/vocab/meta-data": true,
        "https://json-schema.org/draft/2019-09/vocab/format": false,
        "https://json-schema.org/draft/2019-09/vocab/content": true
    },
    "$recursiveAnchor": true,
    "title": "Core and Validation specifications meta-schema",
    "allOf": [
        {"$ref": "meta/core"},
        {"$ref": "meta/applicator"},
        {"$ref": "meta/validation"},
        {"$ref": "meta/meta-data"},
        {"$ref": "meta/format"},
        {"$ref": "meta/content"}
    ],
    "type": ["object", "boolean"],
    "properties": {
        "definitions": {
            "$comment": "While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.",
            "type": "object",
            "additionalProperties": { "$recursiveRef": "#" },
            "default": {}
        },
        "dependencies": {
            "$comment": "\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"",
            "type": "object",
            "additionalProperties": {
                "anyOf": [
                    { "$recursiveRef": "#" },
                    { "$ref": "meta/validation#/$defs/stringArray" }
                ]
            }
        }
    }
}

Json that I'm trying to validate is:

{
  "properties": {
    "field1": {
      "type": "invalid-type",
      "description": "string"
    }
  }
}

As you can see from my json, I've provided invalid type for the field I'm trying to define under properties object. I'm expecting for library to throw validation error, but that is not happening.

Error is thrown however if I switch to draft V7 (which I have), and expected error looks like $.properties.field1.type: does not have a value in the enumeration [array, boolean, integer, null, number, object, string],$.properties.field1.type: should be valid to any of the schemas array
If you use online tool like https://www.jsonschemavalidator.net/, you can verify error being thrown with V2019-09.

Hope this provides you with enough information, if you need anything else, let me know.

Regards,
Milos

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions