Skip to main content

JSONSchema Spec with object-oriented paths

Project description

https://img.shields.io/pypi/v/jsonschema-path.svg https://travis-ci.org/p1c2u/jsonschema-path.svg?branch=master https://img.shields.io/codecov/c/github/p1c2u/jsonschema-path/master.svg?style=flat https://img.shields.io/pypi/pyversions/jsonschema-path.svg https://img.shields.io/pypi/format/jsonschema-path.svg https://img.shields.io/pypi/status/jsonschema-path.svg

About

Object-oriented JSONSchema

Key features

  • Traverse schema like paths

  • Access schema on demand with separate dereferencing accessor layer

Installation

pip install jsonschema-path

Alternatively you can download the code and install from the repository:

pip install -e git+https://github.com/p1c2u/jsonschema-path.git#egg=jsonschema_path

Usage

>>> from jsonschema_path import SchemaPath

>>> d = {
...     "properties": {
...        "info": {
...            "$ref": "#/$defs/Info",
...        },
...     },
...     "$defs": {
...         "Info": {
...             "properties": {
...                 "title": {
...                     "$ref": "http://example.com",
...                 },
...                 "version": {
...                     "type": "string",
...                     "default": "1.0",
...                 },
...             },
...         },
...     },
... }

>>> path = SchemaPath.from_dict(d)

>>> # Stat keys
>>> "properties" in path
True

>>> # Concatenate paths with /
>>> info_path = path / "properties" / "info"

>>> # Stat keys with implicit dereferencing
>>> "properties" in info_path
True

>>> # Concatenate paths with implicit dereferencing
>>> version_path = info_path / "properties" / "version"

>>> # Open content with implicit dereferencing
>>> with version_path.open() as contents:
...     print(contents)
{'type': 'string', 'default': '1.0'}

License

Copyright (c) 2017-2022, Artur Maciag, All rights reserved. Apache-2.0

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

jsonschema_path-0.3.4.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

jsonschema_path-0.3.4-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file jsonschema_path-0.3.4.tar.gz.

File metadata

  • Download URL: jsonschema_path-0.3.4.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for jsonschema_path-0.3.4.tar.gz
Algorithm Hash digest
SHA256 8365356039f16cc65fddffafda5f58766e34bebab7d6d105616ab52bc4297001
MD5 e4a1b0d9967124b71c237e868fe819b5
BLAKE2b-256 6e4541ebc679c2a4fced6a722f624c18d658dee42612b83ea24c1caf7c0eb3a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for jsonschema_path-0.3.4.tar.gz:

Publisher: python-publish.yml on p1c2u/jsonschema-path

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jsonschema_path-0.3.4-py3-none-any.whl.

File metadata

File hashes

Hashes for jsonschema_path-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f502191fdc2b22050f9a81c9237be9d27145b9001c55842bece5e94e382e52f8
MD5 3d31da164d834a32d4b4226e5be116d5
BLAKE2b-256 cb583485da8cb93d2f393bce453adeef16896751f14ba3e2024bc21dc9597646

See more details on using hashes here.

Provenance

The following attestation bundles were made for jsonschema_path-0.3.4-py3-none-any.whl:

Publisher: python-publish.yml on p1c2u/jsonschema-path

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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