First, we would define some base configuration that allows you to fetch, validate, and extract remote schemas:
json-schema-lib.yaml
base_dir: "schemas/"
libs:
lib1:
url: "http://spacejam.com/lib1.tar.gz"
lib2:
url: "http://spacejam.com/lib2.tar.gz"
Given the above config file, a CLI could download, extract, and place the above schema files into schemas/lib/lib1
and schemas/lib/lib2
.
jschemalib install
Now, you can write local schemas that have relative references to your installed libraries:
"$ref": "lib/lib1/whatever.json"
The validator would always set the base URI for all the schemas as file://$(pwd)/schemas
during runtime.
It is up to the user whether they want commit or gitignore the lib files under schema/lib
.
A simple lock file could also be generated that stores the content hashes for every installed schema bundle. A jschemalib check
command could validate those hashes.