Skip to main content

A pre-commit hook for validating files against jsonschemas.

Project description

check-jsonschema

A pre-commit hook for checking files against a JSONSchema. The schema may be specified as a local or remote (HTTP or HTTPS) file.

Remote files are automatically downloaded and cached if possible.

Supported Hooks

The most generic hook is this one:

  • check-jsonschema: Validate JSON or YAML files against a jsonschema on disk or fetched via HTTP(S)

These hooks check known files against schemas provided by Schemastore:

  • check-github-workflows: Validate GitHub Workflows in .github/workflows/

  • check-github-actions: Validate GitHub Actions in .github/actions/ or the action.yml at the repo root

  • check-travis: Validate Travis config

These hooks check known files against schemas provided by other sources:

  • check-azure-pipelines: Validate Azure Pipelines config against the schema provided by Microsoft

Example Usage

Validate GitHub Workflows with Schemastore

You can use the schemastore github workflow schema to lint your GitHub workflow files. This hook is so useful, it's built in as a pre-set. All you need to add to your .pre-commit-config.yaml is this:

- repo: https://github.com/sirosen/check-jsonschema
  rev: 0.3.0
  hooks:
    - id: check-github-workflows

Applying an arbitrary schema to files

There is a more general hook available for running any jsonschema against a file or set of files. For example, to implement the GitHub workflow check manually, you could do this:

- repo: https://github.com/sirosen/check-jsonschema
  rev: 0.3.0
  hooks:
    - id: check-jsonschema
      name: "Check GitHub Workflows"
      language: python
      files: ^\.github/workflows/
      types: [yaml]
      args: ["--schemafile", "https://json.schemastore.org/github-workflow"]

Standalone Usage

You can also pip install check-jsonschema to run the tool manually.

For full usage info:

check-jsonschema --help

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

check-jsonschema-0.3.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

check_jsonschema-0.3.1-py2.py3-none-any.whl (6.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file check-jsonschema-0.3.1.tar.gz.

File metadata

  • Download URL: check-jsonschema-0.3.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5

File hashes

Hashes for check-jsonschema-0.3.1.tar.gz
Algorithm Hash digest
SHA256 26bb85000f919e63a10955fedb1b2b1b5ab79bf863d0dca6c9c1a17d28986237
MD5 84c78e28da112ee7bc488a3e8a14918f
BLAKE2b-256 8cc7d745987f35665e5f46f17dcc2476424e431e3b85440ba8dc735acc6edc5b

See more details on using hashes here.

Provenance

File details

Details for the file check_jsonschema-0.3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: check_jsonschema-0.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5

File hashes

Hashes for check_jsonschema-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7b9fe0c0630a9e38a00cc6c4c6a430aae2fa38b124d72ee3f3b20ce082552577
MD5 6a240449cd535408e49e8744a94dcd03
BLAKE2b-256 4989f9ff801f9969b4bc316d1b64803b7330d9cc988f3abbbd97cd96c14dd8bc

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page