Hyperlink keywords - sgpinkus/json-schema GitHub Wiki

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


NOTE: This information has been incorporated into the specifications, and this page is no longer being updated.


JSON Schema is not just for validation. It can also be used to enrich instances with extra information, including hyper-links.

Links

The links keyword in a schema defines a set of links for instances. The value of the links keyword MUST be an array, and each item in the array MUST be a [Link Description Object](link description object).

If an instance is described by a schema, then the Link Description Objects from that schema are used to define hyper-links for an item. The hyper-links are not the same for all instances, because they depend on information from the instances themselves to calculate all their parameters.

For example, here is a simple schema that defines a single link:

{
    "links": [
        {   
            "href": "http://example.com/",
            "rel": "home"
        }   
    ]   
}

To determine the hyperlinks that an instance has, every Link Description Object in every applicable schema should be considered. This includes schemas specified using extends, inferred from parent schemas using properties or items (and others), or linked to using $ref.

Link templating

Link Description Objects don't explicitly describe links. They actually describe link templates, so that the actual link for each instance is different.

More information about how the hyperlinks are calculated is on the [Link Description Object](link description object) page (in particular href).

⚠️ **GitHub.com Fallback** ⚠️