encoding/jsonschema: better version support
Currently schema version is recognized in an ad-hoc way inside the `id`
and `$id` implementations, but version-specific behavior is going to be
considerably more widespread than that, so implement a way to declare
the set of versions supported by each keyword and have the higher-level
logic do that check.
Also, we need another phase in the processing because `$schema` must be
processed first so we know how to process other keywords that are
currently in phase 0 (eg. `id`), so increment all existing phase numbers
and put `$schema` in phase 0.
The changed behaviour in the `def_jsonschema` test demonstrates that
this does fix some existing code: the `$schema` field is lexically after
the `$id` field so the `$id` field processing was not aware of the
schema that had been set and hence did not recognize the id. The new
phasing fixes this.
Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I4eee68845d3f0632ab062408e0a02299656f63f2
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199533
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>