jsonschema-path 0.3.4


pip install jsonschema-path

  Latest version

Released: Jan 24, 2025

Project Links

Meta
Author: Artur Maciag
Requires Python: >=3.8.0,<4.0.0

Classifiers

Development Status
  • 4 - Beta

Intended Audience
  • Developers

License
  • OSI Approved :: Apache Software License

Operating System
  • OS Independent

Programming Language
  • Python :: 3
  • Python :: 3.8
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13

Topic
  • Software Development :: Libraries
  • Software Development :: Libraries :: Python Modules
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

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras: None
Dependencies:
PyYAML (>=5.1)
pathable (<0.5.0,>=0.4.1)
referencing (<0.37.0)
requests (<3.0.0,>=2.31.0)