json-schema-org / JSON-Schema-Test-Suite

A language agnostic test suite for the JSON Schema specifications
MIT License
625 stars 209 forks source link

doubts about ref.json test. #633

Closed redmitry closed 1 year ago

redmitry commented 1 year ago

Hello,

I have a doubt about the particular test in the test suit ref.json#L179 :

    {
        "description": "$ref prevents a sibling $id from changing the base uri",
        "schema": {
            "$id": "http://localhost:1234/sibling_id/base/",
            "definitions": {
                "foo": {
                    "$id": "http://localhost:1234/sibling_id/foo.json",
                    "type": "string"
                },
                "base_foo": {
                    "$comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json",
                    "$id": "foo.json",
                    "type": "number"
                }
            },
            "allOf": [
                {
                    "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not http://localhost:1234/sibling_id/foo.json",
                    "$id": "http://localhost:1234/sibling_id/",
                    "$ref": "foo.json"
                }
            ]
        },
        "tests": [
            {
                "description": "$ref resolves to /definitions/base_foo, data does not validate",
                "data": "a",
                "valid": false
            },
            {
                "description": "$ref resolves to /definitions/base_foo, data validates",
                "data": 1,
                "valid": true
            }
        ]
    }

Is the "definitions" keyword is just a convention or is a part of the specification? I refer to the draft4 section-7.2.3 My point is that should the validator process "definitions" as the "$defs"? If the "definitions" is just a convention, the validator should dereference it as json pointer an thus the test will FAIL because we do not process it before referencing.

Thank you,

D.