Closed karenetheridge closed 2 years ago
This requires refactoring how we set up a schema document for traversal and evaluation -- we cannot instantiate vocabulary objects with $js->specification_version
as today, as we will have already started traversal by the time we encounter the "$schema" keyword.
FOR NOW:
$js->_traverse_subschema()
, core vocabulary: consider the superset of keywords in the core vocabulary across all specification versions; every core keyword's traverse method needs to check the current specification version (in $state) to see if it is implemented in the current version (because that version can change in the middle of keyword traversal)_eval_subschema
), check document object's cache and set $state->{specification_version}.LATER, when we support different dialects (and hence different vocabularies):
$js->_traverse_subschema
: start off with just the core vocabulary in a newly-instantiated dialect object (uri not yet set)_eval_subschema
), check document object's cache and set dialect object in $state.This is now done, as of release 0.518.
The latest specification allows for $schema to appear anywhere a "schema resource" begins, which iff the "$id" keyword appears. In theory (even before supporting custom dialects) we should be able to switch between specification versions by encountering the "$schema" keyword whose value references one of the other draft specification URIs.
This is a necessary prerequisite for any sort of $vocabulary support (the document described by the URI needs to be loaded and parsed).