json-schema-org/understanding-json-schema

Incorrect `$anchor` example in documentation

Whathecode opened this issue · 0 comments

The current documentation on $anchor includes the following code sample:

{
  "$id": "https://example.com/schemas/address",

  "type": "object",
  "properties": {
    "street_address":
      {
        "$anchor": "#street_address",
        "type": "string"
      },
    "city": { "type": "string" },
    "state": { "type": "string" }
  },
  "required": ["street_address", "city", "state"]
}

Note the anchor name: "$anchor": "#street_address". This shouldn't include the hash: "$anchor": "street_address".

The specification for reference:

The "$anchor" keyword is used to specify such a fragment. It is an identifier keyword that can only be used to create plain name fragments.

If present, the value of this keyword MUST be a string, which MUST start with a letter ([A-Za-z]), followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), or periods ("."). [CREF8]