Skip to main content

perfect-jsonschema

Build Status codecov

Because soft validation is not enough

Why

JSON schema standard and its implementations stand that if you have something unfamiliar in your schema, it's not an error. In particular, you won't get an error if you made a typo or used something you thought as working. For example, this one is perfectly fine and valid:

{
    "required": ["company"],
    "type": "object",
    "propertie": {"company": {"pattern": "^(Apple)$"}, "format": "url"},
}

But we want to catch those propertie typos and invalid url formats.

The library rely on jsonschema and supports additional keywords to ignore.

Features

Derives the draft from the schema and yields a jsonschema.SchemaError if:

  • A schema is empty
  • A schema contains a keyword which is not a part of a jsonschema implementation or extended_keywords set
  • A schema contains an invalid format value
  • A schema fails with jsonschema.check_schema()

Usage

from perfect-jsonschema import check

try:
    check(schema, extended_keywords={"tag"})
except Exception as e:
    do_something()

An exception example:

Traceback (most recent call last):
    f"Schema contains invalid keywords for "
jsonschema.exceptions.SchemaError: Schema contains invalid keywords for http://json-schema.org/draft-07/schema#:
{'propertie', 'company'}

Local development

pipenv install --dev
pipenv shell
tox

Contribution

Any contribution is welcome

Metadata

Release files for perfect-jsonschema 2019.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for perfect-jsonschema 2019.2.6
File Size Uploaded
perfect-jsonschema-2019.2.6.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for perfect-jsonschema 2019.2.6
File Interpreter ABI Platform
perfect_jsonschema-2019.2.6-py3-none-any.whl Python 3 none any Details

Total release size: 16.2 kB

Release files / perfect-jsonschema-2019.2.6.tar.gz

Download URL perfect-jsonschema-2019.2.6.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
441877f9a9ec32716715acc13b5c28f79a34f98f0823178b2d992fa95526bc00
BLAKE2b-256 checksum
How to use checksums
987e1c6c39297d09363e88d53e9d805f0cf1bb39dde67a69801d162529b28207
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.2

Release files / perfect_jsonschema-2019.2.6-py3-none-any.whl

Download URL perfect_jsonschema-2019.2.6-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0dbb049a48eaa1636cacdd6119fd8e6425561fa7f9b028e926774b26517d7aa4
BLAKE2b-256 checksum
How to use checksums
eac1de9bb485f2d7cf7e11ef27a291a80cf31fcc76db59e864d89f21333f656e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.2

Release history Release notifications | RSS feed

This release

2019.2.6 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page