JSONSchema Spec with object-oriented paths
Project description
About
JSONSchema Spec with object-oriented paths
Key features
Traverse elements like paths
Access spec 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 Spec
>>> d = {
... "properties": {
... "info": {
... "$ref": "#/$defs/Info",
... },
... },
... "$defs": {
... "Info": {
... "properties": {
... "title": {
... "$ref": "http://example.com",
... },
... "version": {
... "type": "string",
... "default": "1.0",
... },
... },
... },
... },
... }
>>> spec = Spec.from_dict(d)
>>> # Stat keys
>>> "properties" in spec
True
>>> # Concatenate paths with /
>>> info_spec = spec / "properties" / "info"
>>> # Stat keys with implicit dereferencing
>>> "properties" in info_spec
True
>>> # Concatenate paths with implicit dereferencing
>>> version_spec = info_spec / "properties" / "version"
>>> # Open content with implicit dereferencing
>>> with version_spec.open() as version:
... print(version)
{'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.1.5.tar.gz
(10.3 kB
view hashes)
Built Distribution
Close
Hashes for jsonschema_spec-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b2631b04aff2b1dbb46247627d34db3181056d57a720f4fd4aaaa6b5b51d750 |
|
MD5 | df38bc618f984a167048c82e6274b345 |
|
BLAKE2b-256 | f50fca68b7096777d8c501624a6bbcf42b06f126d060109098e0071e2a8e1f6d |