Skip to content

earthrise-media/schema-validator-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON Schema Validator

Go Report Card FOSSA Status

Known Vulnerabilities

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

Usage

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 repository
  • FORCE_SCHEMA_LOCATION (required) the location of a schema to use for validation(can be file path or http/s)
  • FAIL_FAST (default false) if set the tool will exit on first error

Examples

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

Behavior

Files are validated only if they end in .json or .geojson Validation includes:

  1. Must be valid JSON syntax (i.e. braces and quotes must be closed etc.)
  2. 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

License

FOSSA Status