json-schema-utils 0.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- json_schema_utils-0.8.dist-info/METADATA +119 -0
- json_schema_utils-0.8.dist-info/RECORD +15 -0
- json_schema_utils-0.8.dist-info/WHEEL +5 -0
- json_schema_utils-0.8.dist-info/entry_points.txt +7 -0
- json_schema_utils-0.8.dist-info/licenses/LICENSE +1 -0
- json_schema_utils-0.8.dist-info/top_level.txt +1 -0
- jsutils/__init__.py +5 -0
- jsutils/convert.py +934 -0
- jsutils/inline.py +206 -0
- jsutils/recurse.py +90 -0
- jsutils/schemas.py +151 -0
- jsutils/scripts.py +396 -0
- jsutils/simplify.py +580 -0
- jsutils/stats.py +1310 -0
- jsutils/utils.py +44 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: json_schema_utils
|
|
3
|
+
Version: 0.8
|
|
4
|
+
Summary: JSON Schema Utils
|
|
5
|
+
Author: Fabien Coelho, Claire Yannou-Medrala
|
|
6
|
+
License-Expression: CC0-1.0
|
|
7
|
+
Project-URL: repository, https://github.com/zx80/json-schema-utils
|
|
8
|
+
Classifier: Topic :: Software Development
|
|
9
|
+
Requires-Python: >=3.12
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: requests
|
|
13
|
+
Requires-Dist: jschon
|
|
14
|
+
Requires-Dist: jsonschema[format]
|
|
15
|
+
Provides-Extra: dev
|
|
16
|
+
Requires-Dist: ruff; extra == "dev"
|
|
17
|
+
Requires-Dist: flake8; extra == "dev"
|
|
18
|
+
Requires-Dist: pyright; extra == "dev"
|
|
19
|
+
Provides-Extra: dist
|
|
20
|
+
Requires-Dist: build; extra == "dist"
|
|
21
|
+
Requires-Dist: twine; extra == "dist"
|
|
22
|
+
Requires-Dist: wheel; extra == "dist"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# JSON Schema Utils
|
|
26
|
+
|
|
27
|
+
Random utilities to analyze and manipulate JSON Schema.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
Install latest version with `pip` from PyPI or from GitHub:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
python -m venv venv
|
|
35
|
+
source venv/bin/activate
|
|
36
|
+
# from PyPI:
|
|
37
|
+
pip install json_schema_utils
|
|
38
|
+
# OR from latest sources:
|
|
39
|
+
pip install git+https://github.com/zx80/json-schema-utils.git
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Inline Schema References
|
|
43
|
+
|
|
44
|
+
Replace references `$ref` by their definitions.
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
# no $id
|
|
48
|
+
jsu-inline -m "file:// ./tests" tests/*.schema.json
|
|
49
|
+
# with $id
|
|
50
|
+
jsu-inline -a tests/foo.schema.json
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Simplify Schema
|
|
54
|
+
|
|
55
|
+
Apply various schema simplifications:
|
|
56
|
+
|
|
57
|
+
- remove type-incompatible keywords and formats, with warnings.
|
|
58
|
+
- try to move up list-of-one-schema `*Of`.
|
|
59
|
+
- simplify type lists.
|
|
60
|
+
- change list-of-one `enum` to `const`.
|
|
61
|
+
- detect some cases of infeasible schemas.
|
|
62
|
+
- remove uneffective keywords in corner cases.
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
jsu-simpler tests/*.schema.json
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Check JSON Values against a Schema
|
|
69
|
+
|
|
70
|
+
Check a JSON values match a given schema using either
|
|
71
|
+
[jsonschema](https://github.com/python-jsonschema/jsonschema) or
|
|
72
|
+
[jschon](https://github.com/marksparkza/jschon) implementations.
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
jsu-check tests/foo.schema.json tests/foo.*.value.json
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## JSON Schema Stats and Issues
|
|
79
|
+
|
|
80
|
+
Generate a report about JSON schemas, including possible bugs.
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
jsu-stats tests/*.schema.json
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
This script is extracted from [JSON Schema Stats](https://github.com/clairey-zx81/json-schema-stats)
|
|
87
|
+
which has been updated to depend on this module.
|
|
88
|
+
|
|
89
|
+
## JSON Prettyprinter
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
jsu-pretty --indent 2 --sort-keys tests/*.schema.json
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
You could also use `jq .` for this purpose.
|
|
96
|
+
|
|
97
|
+
## JSON Schema to JSON Model Conversion
|
|
98
|
+
|
|
99
|
+
Convert a subset of JSON Schema to JSON Model.
|
|
100
|
+
The subset should comply with some restrictions described in Section 6 of
|
|
101
|
+
[An Analysis of Defects in Public JSON Schemas](https://minesparis-psl.hal.science/hal-04415517/file/A-794-DepotHAL.pdf)
|
|
102
|
+
by Claire Yannou-Medrala and Fabien Coelho:
|
|
103
|
+
|
|
104
|
+
- `const`, `enum`, `$ref`, `type`, `allOf`, `anyOf`, `oneOf` should be exclusive.
|
|
105
|
+
- some keywords are not supported: `multipleOf`, `contains`
|
|
106
|
+
- conditions `if then else` are translated to the logical equivalent:
|
|
107
|
+
`{if: C, then: T, else: E}` is _(C and T) or (not C and E)_
|
|
108
|
+
|
|
109
|
+
```sh
|
|
110
|
+
jsu-model test/foo.schema.json
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## TODO
|
|
114
|
+
|
|
115
|
+
- Testing. CI.
|
|
116
|
+
- stats: warn instead of errors on unsure issues under `if`/`then`/`else`/`not`.
|
|
117
|
+
- propagate non type under containers (`*Of`, `if`, `then`, `else`, reference?)
|
|
118
|
+
to reduce false positive errors/warnings.
|
|
119
|
+
- simplify: deduplicate constants in enum?
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
json_schema_utils-0.8.dist-info/licenses/LICENSE,sha256=y_yFW1bmBAUFCF-ZDyDiq10Ykns_19If5pFnZUzYgeU,33
|
|
2
|
+
jsutils/__init__.py,sha256=1mAjhf0BQWyBYuQwVCpMmb__nBQ-b3wmFjsbCW9jE_I,181
|
|
3
|
+
jsutils/convert.py,sha256=1k6dAG1IgghWvKYyv7-ldqE0ZTq-D2SgRQaMsGKfu6Q,39998
|
|
4
|
+
jsutils/inline.py,sha256=-LT2m9Jx65ofYmKKgeuaOtrocpjgJ1ujivmRKgB08SA,6773
|
|
5
|
+
jsutils/recurse.py,sha256=Vf3MyXZRNj38tHbBRV9NNkhMAbU4GeOUdDvzpur4fUI,3026
|
|
6
|
+
jsutils/schemas.py,sha256=Y05HAawgrM8Jp-fIPhybPt9Rk6QuEIAJA4uEpWH4GnQ,4729
|
|
7
|
+
jsutils/scripts.py,sha256=d90YTcFoL1PVnyfRHlHTHyGSYnHTAz7Mva7SeVdb4Jg,14135
|
|
8
|
+
jsutils/simplify.py,sha256=21i3Flh068dYTdk3ojf8yu9k2dji9wlJG506YGZreYw,22415
|
|
9
|
+
jsutils/stats.py,sha256=O2aCB52jIfAK0d4z6MT3aK-kDeGbPQDlfL5Ued15OWA,48030
|
|
10
|
+
jsutils/utils.py,sha256=Kn9sQhOY6zlUuucVbm3sohgRhwwWsQzsk874RQAZP0g,1155
|
|
11
|
+
json_schema_utils-0.8.dist-info/METADATA,sha256=WmtO6ASG23GaB1iy33MrSp10ywk6PfPjrOUQo8cgWY4,3257
|
|
12
|
+
json_schema_utils-0.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
13
|
+
json_schema_utils-0.8.dist-info/entry_points.txt,sha256=wfQIGrYmIXTYztrI6z8iiB7t0FobGXFeYnT-cvchNvw,206
|
|
14
|
+
json_schema_utils-0.8.dist-info/top_level.txt,sha256=CCwMrRB4ezSTB7Ql64f8bXL7OEHtptJPPfX4pX6Y2_E,8
|
|
15
|
+
json_schema_utils-0.8.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CC0: This code is Public Domain.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
jsutils
|