You cannot perform referencing with just id
on its own. For referencing, you have to use $ref
.
The id
keyword allows you to supply a URL for the schema as a target for referencing:
{
"id": "http://example.com/schemas/example",
"type": "object",
"properties": {
"arr1": {
"id": "#item-schema",
...
},
"arr2": {"$ref": "#item-schema"}
}
}
This is so that you can reference schemas using nice URLs (e.g. http://example.com/schemas/example#item-schema
) instead of using JSON Pointer fragment syntax. It also allows you to re-organise your schema (e.g. move the item schema into definitions
) without changing the URL.
However, for the referencing itself, you still need to use $ref
. If you need this functionality, you need support for it in whatever tool you're using.