Skip to content

Instantly share code, notes, and snippets.

@jayrbolton
Created August 11, 2020 20:59
Show Gist options
  • Save jayrbolton/e81fa352954bc29aea5bdce5bb4de92d to your computer and use it in GitHub Desktop.
Save jayrbolton/e81fa352954bc29aea5bdce5bb4de92d to your computer and use it in GitHub Desktop.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment