Skip to main content

Pitt JSON Schemas and validators

Project description

pitt_schemas

JSON schemas and validation helpers.

Requirements

  • Python 3.4 or higher

  • jsonschema

  • tox (for running tests)

  • pre-commit (for running linters before committing)

    • After installing pre-commit, install the git-hook scripts:
    $ pre-commit install
    

Installation

The recommended way to install this package is using pip:

pip install pitt_schemas

Usage

This library has one main public method, is_valid(), which takes a dict as the first argument and a schema filename as the second.

from pitt_schemas import is_valid

data = {"key": "value" ... }
is_valid(data, "object.json")

pitt_schemas will attempt to add an appropriate extension to schema filenames in cases where it is either missing or incorrect. For example, if either schema and schema.org as schema filenames, pitt_schemas will attempt to open schema.json.

Invalid data will raise a jsonschema.exceptions.ValidationError, and an invalid schema filename will raise a FileNotFoundError.

Available schemas

All schemas are located in the schemas/ subdirectory of the pitt_schemas/ directory.

Tests

pitt_schemas comes with unit tests as well as linting. The easiest way to make sure all tests pass is to run tox from the root of the repository. This will execute all tests, and will also run autopep8 and flake8 linters against the codebase.

Documentation

Automatically generated HTML documentation in the docs/ directory based upon .json files in the schemas/ subdirectory of the pitt_schemas/ directory.

Requirements

Usage

Running generate_docs.py will iterate over the schemas/ subdirectory and write updated docs files to the docs/ directory.

License

Code is released under an MIT license. SeeLICENSE.md.

Project details


Download files

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

Source Distribution

pitt_schemas-0.2.tar.gz (11.8 kB view details)

Uploaded Source

File details

Details for the file pitt_schemas-0.2.tar.gz.

File metadata

  • Download URL: pitt_schemas-0.2.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.5

File hashes

Hashes for pitt_schemas-0.2.tar.gz
Algorithm Hash digest
SHA256 c18124ec2e73e53853b2c4e34c5b22e4d848578bf5ab82993633f55560e68bb8
MD5 60558e40ae2b67ba958778112cd79de8
BLAKE2b-256 2e4dbe7044fcda1f237733ae2abda3d2b97cbad6ca3cbd5a6560d4bec0a2f021

See more details on using hashes here.

Supported by

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