Skip to content

--check-metaschema doesn't check $ref referenced schemas #464

Open
@rssh22

Description

@rssh22

Considering the next json schema definition:

{
   "title": "main.json"
    "$id": "file://test-schemas/schemas/main.json",
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "required": [
        "metadata"
    ],
    "properties": {
        "metadata": {
            "additionalProperties": false,
            "type": "object",
            "required": [
                "props1",
                "props2"
            ],
            "properties": {
                "props1": {
                    "$ref": "/schemas/props1.json#/props"
                },
                "props2": {
                    "$ref": "/schemas/props2.json#/props"
                }
            }
        }
    }
}
{
    "title": "props1.json"
    "$id": "/schemas/props1.json",
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "props": {
        "type": "object",
        "required": [
            "metadata"
        ],
        "properties": {
            "metadata": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                    "name",
                    "id"
                ],
                "properties": {
                    "name": {
                        "type": "BADstring"
                    },
                    "id": {
                        "type": "integer"
                    }
                }
            }
        }
    }
}
{
   "title": "props2.json"
    "$id": "/schemas/props2.json",
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "props": {
        "type": "object",
        "required": [
            "metadata"
        ],
        "properties": {
            "metadata": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                    "name",
                    "id"
                ],
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "id": {
                        "type": "integer"
                    }
                }
            }
        }
    }
}

I'd like to be able to check fully recursively the schema main.json but it seems that check-jsonchema --check-metaschema main.json doesn't traverse references.

In this case, props1.json schema contains an error. "type" can't be "BADstring" (according to the metaschema". However, the check of main.json returns an ok -- validation done

Am I doing something wrong, there is a bug, or it is feature that could be proposed for enhancement?

thanks in advance!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions