$ref support in various implementations - sgpinkus/json-schema GitHub Wiki

THIS WIKI IS OBSOLETE. PLEASE SEE THE NEW JSON-SCHEMA-ORG/JSON-SCHEMA-SPEC REPOSITORY.


NOTE: This page holds preliminary notes made during work on earlier drafts of the specification, and is not being updated.


Purpose

JSON Schema has two keywords allowing for one schema to refer to another schema, or part of another schema (even itself):

  • $ref,
  • id.

Support for these two keywords vary quite a lot between implementations. This page will list:

  • common usage scenarios for both of these keywords;
  • whether a particular implementation supports this usage scenario.

Usage scenarios

Inline schema reference using JSON Pointer

NOTE: as eventually specified in the JSON Reference draft RFC, it is not valid to have any other properties in the same object as "$ref". Presumably this example predates that decision. Noted here so as not to mislead, but left visible for historical accuracy.

Schema

{
    "$ref": "#/definitions/sub",
    "definitions": {
        "sub": { "type": "string" }
    }
}

Expected results

This:

"foo"

validates sucessfully.

This:

3

fails to validate.

Implementation support

TODO