Within a reference, items were previously (in #74) required to be followed by a valid array index (that is, a natural number). However, it turns out items can both be represented as an array, or as a single schema. In the latter case, it is accessed in a reference without any index.
This commit fixes the handling of items, by parsing separately items followed by a valid array index and not.
Ideally, we would like to dynamically look into the schema to be sure to correctly parse items: in other word, in theory, the parsing of a schema pointer depends on the particular schema at hand.
However, it's simpler to do the parsing independently of any schema, so this PR decides between the two possibilities (array or single element) by looking at whether the following element in the JSON pointer is a valid array index or not. This is sufficient in the case of JSON schemas, because there's no schema property with a name that is also a valid array index: that is, when seeing items/0, we know that items can't be a single value because then 0 wouldn't be a valid schema property.
Depends on #74.
Within a reference,
items
were previously (in #74) required to be followed by a valid array index (that is, a natural number). However, it turns outitems
can both be represented as an array, or as a single schema. In the latter case, it is accessed in a reference without any index.This commit fixes the handling of items, by parsing separately
items
followed by a valid array index and not.Ideally, we would like to dynamically look into the schema to be sure to correctly parse
items
: in other word, in theory, the parsing of a schema pointer depends on the particular schema at hand.However, it's simpler to do the parsing independently of any schema, so this PR decides between the two possibilities (array or single element) by looking at whether the following element in the JSON pointer is a valid array index or not. This is sufficient in the case of JSON schemas, because there's no schema property with a name that is also a valid array index: that is, when seeing
items/0
, we know thatitems
can't be a single value because then0
wouldn't be a valid schema property.