json-schema-utils 0.8__tar.gz

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.
@@ -0,0 +1,171 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # PyPI configuration file
171
+ .pypirc
@@ -0,0 +1 @@
1
+ CC0: This code is Public Domain.
@@ -0,0 +1 @@
1
+ recursive-exclude tests *
@@ -0,0 +1,76 @@
1
+ SHELL = /bin/bash
2
+ .ONESHELL:
3
+
4
+ .PHONY: clean
5
+ clean:
6
+ $(RM) *~
7
+ $(RM) -r jsutils/__pycache__ dist/
8
+
9
+ .PHONY: clean.dev
10
+ clean.dev: clean
11
+ $(RM) -rf venv *.egg-info
12
+
13
+ .PHONY: dev
14
+ dev: venv
15
+
16
+ venv:
17
+ python -m venv venv
18
+ source venv/bin/activate
19
+ pip install -e .[dev]
20
+
21
+ .PHONY: check
22
+ check: check.inline check.simpler check.src check.tests
23
+
24
+ .PHONY: check.src
25
+ check.src: check.ruff check.flake8 check.pyright
26
+
27
+ .PHONY: check.tests
28
+ check.tests: dev
29
+ source venv/bin/activate
30
+ $(MAKE) -C tests check
31
+
32
+ IGNORE = E201,E202,E227,E302,E402,E731
33
+
34
+ .PHONY: check.ruff
35
+ check.ruff: venv
36
+ source venv/bin/activate
37
+ ruff check --ignore=$(IGNORE) jsutils
38
+
39
+ .PHONY: check.flake8
40
+ check.flake8: venv
41
+ source venv/bin/activate
42
+ flake8 --ignore=$(IGNORE),W504 --max-line-length=100 jsutils
43
+
44
+ .PHONY: check.pyright
45
+ check.pyright: venv
46
+ source venv/bin/activate
47
+ pyright jsutils
48
+
49
+ .PHONY: check.inline
50
+ check.inline: venv
51
+ source venv/bin/activate
52
+ $(MAKE) -C tests inline
53
+
54
+ .PHONY: check.simpler
55
+ check.simpler: venv
56
+ source venv/bin/activate
57
+ $(MAKE) -C tests simpler
58
+
59
+ .PHONY: check.stats
60
+ check.stats: venv
61
+ source venv/bin/activate
62
+ $(MAKE) -C tests stats
63
+
64
+ #
65
+ # publication on pypi
66
+ #
67
+ # pip install -e .[dist]
68
+ # make publish
69
+ # twine upload dist/*
70
+ #
71
+ .PHONY: publish
72
+ publish:
73
+ source venv/bin/activate
74
+ python -m build
75
+ twine check dist/*
76
+ echo "# twine upload dist/*"
@@ -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,95 @@
1
+ # JSON Schema Utils
2
+
3
+ Random utilities to analyze and manipulate JSON Schema.
4
+
5
+ ## Installation
6
+
7
+ Install latest version with `pip` from PyPI or from GitHub:
8
+
9
+ ```sh
10
+ python -m venv venv
11
+ source venv/bin/activate
12
+ # from PyPI:
13
+ pip install json_schema_utils
14
+ # OR from latest sources:
15
+ pip install git+https://github.com/zx80/json-schema-utils.git
16
+ ```
17
+
18
+ ## Inline Schema References
19
+
20
+ Replace references `$ref` by their definitions.
21
+
22
+ ```sh
23
+ # no $id
24
+ jsu-inline -m "file:// ./tests" tests/*.schema.json
25
+ # with $id
26
+ jsu-inline -a tests/foo.schema.json
27
+ ```
28
+
29
+ ## Simplify Schema
30
+
31
+ Apply various schema simplifications:
32
+
33
+ - remove type-incompatible keywords and formats, with warnings.
34
+ - try to move up list-of-one-schema `*Of`.
35
+ - simplify type lists.
36
+ - change list-of-one `enum` to `const`.
37
+ - detect some cases of infeasible schemas.
38
+ - remove uneffective keywords in corner cases.
39
+
40
+ ```sh
41
+ jsu-simpler tests/*.schema.json
42
+ ```
43
+
44
+ ## Check JSON Values against a Schema
45
+
46
+ Check a JSON values match a given schema using either
47
+ [jsonschema](https://github.com/python-jsonschema/jsonschema) or
48
+ [jschon](https://github.com/marksparkza/jschon) implementations.
49
+
50
+ ```sh
51
+ jsu-check tests/foo.schema.json tests/foo.*.value.json
52
+ ```
53
+
54
+ ## JSON Schema Stats and Issues
55
+
56
+ Generate a report about JSON schemas, including possible bugs.
57
+
58
+ ```sh
59
+ jsu-stats tests/*.schema.json
60
+ ```
61
+
62
+ This script is extracted from [JSON Schema Stats](https://github.com/clairey-zx81/json-schema-stats)
63
+ which has been updated to depend on this module.
64
+
65
+ ## JSON Prettyprinter
66
+
67
+ ```sh
68
+ jsu-pretty --indent 2 --sort-keys tests/*.schema.json
69
+ ```
70
+
71
+ You could also use `jq .` for this purpose.
72
+
73
+ ## JSON Schema to JSON Model Conversion
74
+
75
+ Convert a subset of JSON Schema to JSON Model.
76
+ The subset should comply with some restrictions described in Section 6 of
77
+ [An Analysis of Defects in Public JSON Schemas](https://minesparis-psl.hal.science/hal-04415517/file/A-794-DepotHAL.pdf)
78
+ by Claire Yannou-Medrala and Fabien Coelho:
79
+
80
+ - `const`, `enum`, `$ref`, `type`, `allOf`, `anyOf`, `oneOf` should be exclusive.
81
+ - some keywords are not supported: `multipleOf`, `contains`
82
+ - conditions `if then else` are translated to the logical equivalent:
83
+ `{if: C, then: T, else: E}` is _(C and T) or (not C and E)_
84
+
85
+ ```sh
86
+ jsu-model test/foo.schema.json
87
+ ```
88
+
89
+ ## TODO
90
+
91
+ - Testing. CI.
92
+ - stats: warn instead of errors on unsure issues under `if`/`then`/`else`/`not`.
93
+ - propagate non type under containers (`*Of`, `if`, `then`, `else`, reference?)
94
+ to reduce false positive errors/warnings.
95
+ - simplify: deduplicate constants in enum?
@@ -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,21 @@
1
+ .gitignore
2
+ LICENSE
3
+ MANIFEST.in
4
+ Makefile
5
+ README.md
6
+ pyproject.toml
7
+ json_schema_utils.egg-info/PKG-INFO
8
+ json_schema_utils.egg-info/SOURCES.txt
9
+ json_schema_utils.egg-info/dependency_links.txt
10
+ json_schema_utils.egg-info/entry_points.txt
11
+ json_schema_utils.egg-info/requires.txt
12
+ json_schema_utils.egg-info/top_level.txt
13
+ jsutils/__init__.py
14
+ jsutils/convert.py
15
+ jsutils/inline.py
16
+ jsutils/recurse.py
17
+ jsutils/schemas.py
18
+ jsutils/scripts.py
19
+ jsutils/simplify.py
20
+ jsutils/stats.py
21
+ jsutils/utils.py
@@ -0,0 +1,7 @@
1
+ [console_scripts]
2
+ jsu-check = jsutils:jsu_check
3
+ jsu-inline = jsutils:jsu_inline
4
+ jsu-model = jsutils:jsu_model
5
+ jsu-pretty = jsutils:jsu_pretty
6
+ jsu-simpler = jsutils:jsu_simpler
7
+ jsu-stats = jsutils:jsu_stats
@@ -0,0 +1,13 @@
1
+ requests
2
+ jschon
3
+ jsonschema[format]
4
+
5
+ [dev]
6
+ ruff
7
+ flake8
8
+ pyright
9
+
10
+ [dist]
11
+ build
12
+ twine
13
+ wheel
@@ -0,0 +1,5 @@
1
+ from jsutils.scripts import (
2
+ jsu_inline, jsu_simpler, jsu_check, jsu_stats, jsu_pretty, jsu_model
3
+ )
4
+
5
+ _ = [jsu_inline, jsu_simpler, jsu_check, jsu_stats, jsu_pretty, jsu_model]