Working with the Schema
Currently, WE1S offers a simple tool for validating manifests against the schema. Schema files are files in the JSON Schema format with names like schema_name.json
. Software to validate manifests against these schema files is available for a variety of programming languages. The WE1S Project provides sample manifests of each type with names like Sources.json
.
Validating a Manifest against a Schema
In this section we demonstrate a method of validating manifests against the schema in Python using the jsonschema
library. You can install it with
pip install jsonschema
WE1S provides a convenient validate.py
script in the schema
folder, which can be used to validate manifests or adapted for use in validation routines elsewhere. validate.py
is a command line tool which accepts a path to the schema file and a path to the data file you wish to validate. The script accepts urls, so you can validate against the apropriate schema files in the GitHub repository's schema
folder (make sure to use the url for the "raw" code). There are also a set of test files in the schema's tests
folder.
Note
jsonschema
validation errors are often less informative than one would like. But at least you know that there is the data is invalid. If it is not clear what is wrong, it is worth checking whether the manifest is well-formed JSON using jsonlint. If this does not reveal the problem, then the manifest does not follow the WE1S manifest schema in some way.