Previous draft support
For version 1, the JSON::Schema library needs to support JSON Schema Draft 1 and JSON Schema Draft 2.
Does different drafts support require explicit version switching? If so, how one will be able to switch it?
I'd like to support explicit and implicit version switching; I'm going to include an option that can be passed to the Validator to only validate against a specific version of the spec, but if this option is not set, it will try its best to determine the version of the spec the schema is adhering to.
I say "try its best" mostly because the "$schema" attribute, which is used to define the schema of the schema (and thus the version of the spec used) was introduced in Draft 3. All previous versions of the draft used a "describedBy" relation that was not part of the core schema. This relation was intended to be defined outside of the schema itself as part of a MIME-type or transfer medium header, and allowed for multiple 'describedBy' relations to be defined for a specific document.
More than likely I'll just expect the '$schema' property to be set even in older versions of the spec if the user wants this validator to validate implicitly against older specs. This will allow for schema environments to be mixed (i.e. draft-02 schemas referenced from draft-03 schemas) and still validate properly.
I added support for draft1 and draft2 in 0.9.0. As described above, you can utilize draft1 / draft2 validation by either of the following:
- Utilizing the
$schemaparameter, linking to the appropriate schema spec being used. This attribute is undefined in draft1 and draft2, but will be recognized. - A new option,
:version, has been added to thevalidateoption. This value can be either:draft1or:draft2. An example has been added to the README.
The $schema parameter will always take precedence over the :version option.