Liquid Studio 2020
In This Topic
    Reference Resolution
    In This Topic

    The Json Schema allows schemas to be defined inline or retrieved from a reference.

    To indicate a reference the $ref keyword is used with the value being the reference to the schema using the JSON Pointer convention.

     

    Json Schema Source
    Copy Code
    {
        "$schema": "http://json-schema.org/draft-04/schema#",
        "type": "object",
        "additionalProperties": false,
        "properties": {
            "ProductCode": {
                "$ref": "#/definitions/ProductCodeType"
            }
        },
        "definitions": {
            "ProductCodeType": {
                "type": "string",
                "pattern": "[A-Z][0-9]*"
            }
        }
    }
    

    The resolution of a reference is carried out as follows.

    So working through our example, let's assume our schema is at http://example/test.json.

     

    The referenced schema may be in another schema file.

    This is an over simplification of the resolution process as the id keyword comes into play while calculating the contexts.

    Put simply if a schema has an id keyword then its context is taken from it and not the name of the schema name.

    The use of id's significantly complicates schemas and is beyond the scope of this documentation.

    The complexity that belies it is only hinted at within the Json schema standard.

    See The id conundrum, Understanding Json Schema for a better description of the issues.