This is a utility (and Github action) that recursively walks a directory and validates all JSON files that it finds. Based on this great validation library
The schema-validator
looks for the following environment variables to control it's behavior:
GITHUB_WORKSPACE
the directory to walk, all subdirectories are also inspected. When run as an action github will populate this value with the root of the repositoryFORCE_SCHEMA_LOCATION
(required) the location of a schema to use for validation(can be file path or http/s)FAIL_FAST
(defaultfalse
) if set the tool will exit on first error
Make sure every JSON file on your machine is GeoJSON, fail if one isn't:
$ env FAIL_FAST=true REQUIRE_SCHEMAS=https://json.schemastore.org/geojson.json GITHUB_WORKSPACE=/ schema-validator
Inside a GitHub workflow yaml file:
steps:
- uses: actions/checkout@v2
- uses: earthrise-media/schema-validator-action@main
Files are validated only if they end in .json
or .geojson
Validation includes:
- Must be valid JSON syntax (i.e. braces and quotes must be closed etc.)
- Schema validation:
- If a schema is provided to the tool (using the
FORCE_SCHEMA_LOCATION
env var) it will override any schema declared in the JSON file - If no schema is provided the file will be validated using any schema declared in a top level
$schema
field - If no schema is found in the file, it will be considered valid unless the
REQUIRE_SCHEMAS
env var is set, in which case it will be considered a failure
- If a schema is provided to the tool (using the