JSONSchema Spec with object-oriented paths
Project description
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
Project details
Release history Release notifications | RSS feed
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.4.tar.gz
(11.5 kB
view details)
Built Distribution
File details
Details for the file jsonschema_spec-0.2.4.tar.gz
.
File metadata
- Download URL: jsonschema_spec-0.2.4.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1042-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 873e396ad1ba6edf9f52d6174c110d4fafb7b5f5894744246a53fe75e5251ec2 |
|
MD5 | 83fb894426da3d4a5a4b36e40d46172b |
|
BLAKE2b-256 | 85bf5e9a059f611e8950eec986385892f9d596e4936fa58a37bf295789197f77 |
File details
Details for the file jsonschema_spec-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: jsonschema_spec-0.2.4-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1042-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6dcf7056734ec6854f7888da6c08ce6c421f28aeeddce96bb90de0fb6d711ef |
|
MD5 | 9f22d87fabc256ec0b0506c58cf17328 |
|
BLAKE2b-256 | d9a27759a4268e1d6d74559de8fb5be6c77d621b822ae64d28ab4f7467c22f63 |