About
Object-oriented JSONSchema
Key features
Traverse schema like paths
Access schema on demand with separate dereferencing accessor layer
Installation
pip install jsonschema-spec
Alternatively you can download the code and install from the repository:
pip install -e git+https://github.com/p1c2u/jsonschema-spec.git#egg=jsonschema_spec
Usage
>>> from jsonschema_spec 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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jsonschema_spec-0.2.2.tar.gz
(11.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jsonschema_spec-0.2.2.tar.gz.
File metadata
- Download URL: jsonschema_spec-0.2.2.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/1.5.1 CPython/3.11.3 Linux/5.15.0-1038-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5c98c2b0be73a1b3cf8464b8a300210d1006eb086ffb9fb0e58b19052ec86ec
|
|
| MD5 |
b871cc550f3fd12a039c087e1f420dec
|
|
| BLAKE2b-256 |
f5ba683ef5e4e5a9a18006447971283d81683b62c405338932c68979dd8e3e85
|
File details
Details for the file jsonschema_spec-0.2.2-py3-none-any.whl.
File metadata
- Download URL: jsonschema_spec-0.2.2-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/1.5.1 CPython/3.11.3 Linux/5.15.0-1038-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a4be06134787e4d747dfb68851b9f9bceafcaa90647a852e8e8993af11705e2
|
|
| MD5 |
bcc5e5be86a832a53a5cc5ea3f883537
|
|
| BLAKE2b-256 |
8c294ffa18d4395754e17ee3460c8b9dc4482152f07f0f1b1879c277130d154d
|