jsonschema-diff 0.1.0__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.
- jsonschema_diff-0.1.0/LICENSE +21 -0
- jsonschema_diff-0.1.0/PKG-INFO +292 -0
- jsonschema_diff-0.1.0/README.md +230 -0
- jsonschema_diff-0.1.0/jsonschema_diff/__init__.py +17 -0
- jsonschema_diff-0.1.0/jsonschema_diff/cli.py +190 -0
- jsonschema_diff-0.1.0/jsonschema_diff/color/__init__.py +12 -0
- jsonschema_diff-0.1.0/jsonschema_diff/color/abstraction.py +62 -0
- jsonschema_diff-0.1.0/jsonschema_diff/color/base.py +124 -0
- jsonschema_diff-0.1.0/jsonschema_diff/color/stages/__init__.py +31 -0
- jsonschema_diff-0.1.0/jsonschema_diff/color/stages/mono_lines.py +112 -0
- jsonschema_diff-0.1.0/jsonschema_diff/color/stages/path.py +191 -0
- jsonschema_diff-0.1.0/jsonschema_diff/color/stages/replace.py +184 -0
- jsonschema_diff-0.1.0/jsonschema_diff/config_maker.py +100 -0
- jsonschema_diff-0.1.0/jsonschema_diff/core/__init__.py +7 -0
- jsonschema_diff-0.1.0/jsonschema_diff/core/abstraction.py +51 -0
- jsonschema_diff-0.1.0/jsonschema_diff/core/config.py +100 -0
- jsonschema_diff-0.1.0/jsonschema_diff/core/custom_compare/__init__.py +7 -0
- jsonschema_diff-0.1.0/jsonschema_diff/core/custom_compare/list.py +98 -0
- jsonschema_diff-0.1.0/jsonschema_diff/core/custom_compare/range.py +241 -0
- jsonschema_diff-0.1.0/jsonschema_diff/core/parameter_base.py +118 -0
- jsonschema_diff-0.1.0/jsonschema_diff/core/parameter_combined.py +36 -0
- jsonschema_diff-0.1.0/jsonschema_diff/core/property.py +243 -0
- jsonschema_diff-0.1.0/jsonschema_diff/core/tools/__init__.py +6 -0
- jsonschema_diff-0.1.0/jsonschema_diff/core/tools/combine.py +105 -0
- jsonschema_diff-0.1.0/jsonschema_diff/core/tools/compare.py +77 -0
- jsonschema_diff-0.1.0/jsonschema_diff/core/tools/context.py +127 -0
- jsonschema_diff-0.1.0/jsonschema_diff/core/tools/render.py +128 -0
- jsonschema_diff-0.1.0/jsonschema_diff/pypi_interface.py +187 -0
- jsonschema_diff-0.1.0/jsonschema_diff/sphinx/__init__.py +32 -0
- jsonschema_diff-0.1.0/jsonschema_diff/sphinx/directive.py +136 -0
- jsonschema_diff-0.1.0/jsonschema_diff/table_render.py +227 -0
- jsonschema_diff-0.1.0/jsonschema_diff.egg-info/PKG-INFO +292 -0
- jsonschema_diff-0.1.0/jsonschema_diff.egg-info/SOURCES.txt +38 -0
- jsonschema_diff-0.1.0/jsonschema_diff.egg-info/dependency_links.txt +1 -0
- jsonschema_diff-0.1.0/jsonschema_diff.egg-info/entry_points.txt +2 -0
- jsonschema_diff-0.1.0/jsonschema_diff.egg-info/requires.txt +15 -0
- jsonschema_diff-0.1.0/jsonschema_diff.egg-info/top_level.txt +1 -0
- jsonschema_diff-0.1.0/pyproject.toml +96 -0
- jsonschema_diff-0.1.0/setup.cfg +4 -0
- jsonschema_diff-0.1.0/tests/test_table_render.py +131 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Miskler
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jsonschema-diff
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A library for comparing JSON schemas and displaying differences
|
|
5
|
+
Author-email: Miskler <mail@miskler.ru>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025 Miskler
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/Miskler/jsonschema-diff
|
|
29
|
+
Project-URL: Repository, https://github.com/yourusername/jsonschema-diff
|
|
30
|
+
Project-URL: Documentation, https://miskler.github.io/jsonschema-diff/basic/quick_start/index.html
|
|
31
|
+
Project-URL: Issues, https://github.com/Miskler/jsonschema-diff/issues
|
|
32
|
+
Keywords: json,schema,diff,comparison
|
|
33
|
+
Classifier: Development Status :: 4 - Beta
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Operating System :: OS Independent
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
43
|
+
Classifier: Topic :: Utilities
|
|
44
|
+
Requires-Python: >=3.10
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
License-File: LICENSE
|
|
47
|
+
Requires-Dist: rich
|
|
48
|
+
Provides-Extra: dev
|
|
49
|
+
Requires-Dist: pytest; extra == "dev"
|
|
50
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
51
|
+
Requires-Dist: pytest-xdist; extra == "dev"
|
|
52
|
+
Requires-Dist: black; extra == "dev"
|
|
53
|
+
Requires-Dist: isort; extra == "dev"
|
|
54
|
+
Requires-Dist: mypy; extra == "dev"
|
|
55
|
+
Requires-Dist: flake8; extra == "dev"
|
|
56
|
+
Requires-Dist: sphinx; extra == "dev"
|
|
57
|
+
Requires-Dist: sphinx-autoapi; extra == "dev"
|
|
58
|
+
Requires-Dist: furo; extra == "dev"
|
|
59
|
+
Requires-Dist: docutils; extra == "dev"
|
|
60
|
+
Requires-Dist: types-docutils; extra == "dev"
|
|
61
|
+
Dynamic: license-file
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
<div align="center">
|
|
65
|
+
|
|
66
|
+
# π JSON Schema Diff
|
|
67
|
+
|
|
68
|
+
<img src="./assets/logo.webp" width="70%" alt="example_working.svg" />
|
|
69
|
+
|
|
70
|
+
*A powerful, intelligent library for comparing JSON schemas with **beautiful formatted output**, **smart parameter combination**, and **contextual information**.*
|
|
71
|
+
|
|
72
|
+
[](https://miskler.github.io/jsonschema-diff/tests/tests-report.html)
|
|
73
|
+
[](https://miskler.github.io/jsonschema-diff/coverage/)
|
|
74
|
+
[](https://python.org)
|
|
75
|
+
[](https://pypi.org/project/jsonschema-diff/)
|
|
76
|
+
[](LICENSE)
|
|
77
|
+
[](https://github.com/psf/black)
|
|
78
|
+
[](https://discord.gg/UnJnGHNbBp)
|
|
79
|
+
[](https://t.me/miskler_dev)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
**[β Star us on GitHub](https://github.com/Miskler/jsonschema-diff)** | **[π Read the Docs](https://miskler.github.io/jsonschema-diff/basic/quick_start/)** | **[π Report Bug](https://github.com/Miskler/jsonschema-diff/issues)**
|
|
83
|
+
|
|
84
|
+
## β¨ Features
|
|
85
|
+
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
- π― **Intelligent Comparison** - Detects and categorizes all types of schema changes
|
|
89
|
+
- π¨ **Beautiful Output** - Colored, formatted differences with clear symbols
|
|
90
|
+
- π **Smart Combination** - Combines related parameters *(e.g., `minimum` + `maximum` = `range`)*
|
|
91
|
+
- π **Context Aware** - Shows related fields for better understanding *(e.g., `type` + `format`)*
|
|
92
|
+
- β‘ **High Performance** - Efficient algorithms for large schemas
|
|
93
|
+
- π οΈ **CLI & Python API & Sphinx Extension** - Use programmatically or from command line or in `.rst`
|
|
94
|
+
- π§ **Highly Configurable** - Customize behavior for your needs
|
|
95
|
+
|
|
96
|
+
<div align="center">
|
|
97
|
+
|
|
98
|
+
## π Quick Start
|
|
99
|
+
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
### Installation
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Standard installation
|
|
106
|
+
pip install jsonschema-diff
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 30-Second Example
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from jsonschema_diff import JsonSchemaDiff, ConfigMaker
|
|
113
|
+
from jsonschema_diff.color import HighlighterPipeline
|
|
114
|
+
from jsonschema_diff.color.stages import (
|
|
115
|
+
MonoLinesHighlighter, ReplaceGenericHighlighter, PathHighlighter
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
prop = JsonSchemaDiff(
|
|
119
|
+
config=ConfigMaker.make(),
|
|
120
|
+
colorize_pipeline=HighlighterPipeline([
|
|
121
|
+
MonoLinesHighlighter(),
|
|
122
|
+
ReplaceGenericHighlighter(),
|
|
123
|
+
PathHighlighter(),
|
|
124
|
+
])
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
prop.compare(
|
|
128
|
+
old_schema="context.old.schema.json",
|
|
129
|
+
new_schema="context.new.schema.json"
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
prop.print(with_legend=True)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Output:**
|
|
136
|
+

|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
### CLI Usage
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Compare schema files
|
|
143
|
+
jsonschema-diff schema_v1.json schema_v2.json
|
|
144
|
+
|
|
145
|
+
# No colors (for logs/CI) and with exit-code
|
|
146
|
+
jsonschema-diff --no-color --exit-code schema_v1.json schema_v2.json
|
|
147
|
+
|
|
148
|
+
# Compare JSON strings
|
|
149
|
+
jsonschema-diff "{\"type\":\"string\"}" "{\"type\":\"number\"}"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
### Sphinx Extension
|
|
154
|
+
|
|
155
|
+
Use the extension in your build:
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
extensions += ["jsonschema_diff.sphinx"]
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
You must also configure the extension. Add the following variable to your `conf.py`:
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from jsonschema_diff import ConfigMaker, JsonSchemaDiff
|
|
165
|
+
from jsonschema_diff.color import HighlighterPipeline
|
|
166
|
+
from jsonschema_diff.color.stages import (
|
|
167
|
+
MonoLinesHighlighter, PathHighlighter, ReplaceGenericHighlighter,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
jsonschema_diff = JsonSchemaDiff(
|
|
171
|
+
config=ConfigMaker.make(),
|
|
172
|
+
colorize_pipeline=HighlighterPipeline(
|
|
173
|
+
[MonoLinesHighlighter(), ReplaceGenericHighlighter(), PathHighlighter()],
|
|
174
|
+
),
|
|
175
|
+
)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
After that, you can use it in your `.rst` files:
|
|
179
|
+
|
|
180
|
+
```rst
|
|
181
|
+
.. jsonschemadiff:: path/to/file.old.schema.json path/to/file.new.schema.json # from folder `source`
|
|
182
|
+
:name: filename.svg # optional
|
|
183
|
+
:title: Title in virtual terminal # optional
|
|
184
|
+
:no-legend: # optional
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
<div align="center">
|
|
189
|
+
|
|
190
|
+
## π Output Format
|
|
191
|
+
|
|
192
|
+
| Symbol | Meaning | Color | Example |
|
|
193
|
+
|--------|---------|-------|---------|
|
|
194
|
+
| `+` | Added | π’ Green | `+ ["new_field"].field: "string"` |
|
|
195
|
+
| `-` | Removed | π΄ Red | `- ["old_field"].field: "string"` |
|
|
196
|
+
| `r` | Changed | π΅ Cyan | `r ["field"].field: "old" -> "new"` |
|
|
197
|
+
| `m` | Modified | π΅ Cyan | `m ["field"]: ...` |
|
|
198
|
+
| ` ` | Context | βͺ None | ` ["related"]: "unchanged"` |
|
|
199
|
+
|
|
200
|
+
## ποΈ Architecture
|
|
201
|
+
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
Modern 6-stage pipeline for clean, testable code:
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
βββββββββββββββ βββββββββββββββββ ββββββββββββββββββββ
|
|
208
|
+
β DiffFinder βββββΆβ CompareFinder βββββΆβ CombineProcessor β
|
|
209
|
+
βββββββββββββββ βββββββββββββββββ ββββββββββββββββββββ
|
|
210
|
+
βΌ
|
|
211
|
+
βββββββββββββββ βββββββββββββββββ βββββββββββββββββ
|
|
212
|
+
β Formatter ββββββRenderProcessorββββββββ DiffProcessor β
|
|
213
|
+
βββββββββββββββ βββββββββββββββββ βββββββββββββββββ
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
1. **DiffFinder**: Finds raw differences
|
|
217
|
+
2. **CompareProcessor**: Find class-processors
|
|
218
|
+
3. **Combiner**: Combines related parameters
|
|
219
|
+
4. **RenderProcessor**: Adds context information and render
|
|
220
|
+
5. **Formatter**: Beautiful colored output
|
|
221
|
+
|
|
222
|
+
<div align="center">
|
|
223
|
+
|
|
224
|
+
## π οΈ Development
|
|
225
|
+
|
|
226
|
+
</div>
|
|
227
|
+
|
|
228
|
+
### Setup
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
git clone https://github.com/Miskler/jsonschema-diff.git
|
|
232
|
+
cd jsonschema-diff
|
|
233
|
+
python -m venv .venv
|
|
234
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
235
|
+
make build
|
|
236
|
+
make install-dev
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Commands
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
# Checks
|
|
243
|
+
make test # Run tests with coverage
|
|
244
|
+
make lint # Lint code
|
|
245
|
+
make type-check # Type checking
|
|
246
|
+
# Action
|
|
247
|
+
make format # Format code
|
|
248
|
+
make docs # Build documentation
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
<div align="center">
|
|
252
|
+
|
|
253
|
+
## π Documentation
|
|
254
|
+
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
- **[π Full Documentation](https://miskler.github.io/jsonschema-diff/)**
|
|
258
|
+
- **[π Quick Start Guide](https://miskler.github.io/jsonschema-diff/basic/quick_start/)**
|
|
259
|
+
- **[π§ API Reference](https://miskler.github.io/jsonschema-diff/reference/api/index.html)**
|
|
260
|
+
|
|
261
|
+
<div align="center">
|
|
262
|
+
|
|
263
|
+
## π€ Contributing
|
|
264
|
+
|
|
265
|
+
### ***We welcome contributions!***
|
|
266
|
+
|
|
267
|
+
### Quick Contribution Setup
|
|
268
|
+
|
|
269
|
+
</div>
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Fork the repo, then:
|
|
273
|
+
git clone https://github.com/your-username/jsonschema-diff.git
|
|
274
|
+
cd jsonschema-diff
|
|
275
|
+
# Install
|
|
276
|
+
make build
|
|
277
|
+
make install-dev
|
|
278
|
+
# Ensure everything works
|
|
279
|
+
make test
|
|
280
|
+
make lint
|
|
281
|
+
make type-check
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
<div align="center">
|
|
285
|
+
|
|
286
|
+
## π License
|
|
287
|
+
|
|
288
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
289
|
+
|
|
290
|
+
*Made with β€οΈ for developers working with evolving JSON schemas*
|
|
291
|
+
|
|
292
|
+
</div>
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
|
|
2
|
+
<div align="center">
|
|
3
|
+
|
|
4
|
+
# π JSON Schema Diff
|
|
5
|
+
|
|
6
|
+
<img src="./assets/logo.webp" width="70%" alt="example_working.svg" />
|
|
7
|
+
|
|
8
|
+
*A powerful, intelligent library for comparing JSON schemas with **beautiful formatted output**, **smart parameter combination**, and **contextual information**.*
|
|
9
|
+
|
|
10
|
+
[](https://miskler.github.io/jsonschema-diff/tests/tests-report.html)
|
|
11
|
+
[](https://miskler.github.io/jsonschema-diff/coverage/)
|
|
12
|
+
[](https://python.org)
|
|
13
|
+
[](https://pypi.org/project/jsonschema-diff/)
|
|
14
|
+
[](LICENSE)
|
|
15
|
+
[](https://github.com/psf/black)
|
|
16
|
+
[](https://discord.gg/UnJnGHNbBp)
|
|
17
|
+
[](https://t.me/miskler_dev)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
**[β Star us on GitHub](https://github.com/Miskler/jsonschema-diff)** | **[π Read the Docs](https://miskler.github.io/jsonschema-diff/basic/quick_start/)** | **[π Report Bug](https://github.com/Miskler/jsonschema-diff/issues)**
|
|
21
|
+
|
|
22
|
+
## β¨ Features
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
- π― **Intelligent Comparison** - Detects and categorizes all types of schema changes
|
|
27
|
+
- π¨ **Beautiful Output** - Colored, formatted differences with clear symbols
|
|
28
|
+
- π **Smart Combination** - Combines related parameters *(e.g., `minimum` + `maximum` = `range`)*
|
|
29
|
+
- π **Context Aware** - Shows related fields for better understanding *(e.g., `type` + `format`)*
|
|
30
|
+
- β‘ **High Performance** - Efficient algorithms for large schemas
|
|
31
|
+
- π οΈ **CLI & Python API & Sphinx Extension** - Use programmatically or from command line or in `.rst`
|
|
32
|
+
- π§ **Highly Configurable** - Customize behavior for your needs
|
|
33
|
+
|
|
34
|
+
<div align="center">
|
|
35
|
+
|
|
36
|
+
## π Quick Start
|
|
37
|
+
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
### Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Standard installation
|
|
44
|
+
pip install jsonschema-diff
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 30-Second Example
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from jsonschema_diff import JsonSchemaDiff, ConfigMaker
|
|
51
|
+
from jsonschema_diff.color import HighlighterPipeline
|
|
52
|
+
from jsonschema_diff.color.stages import (
|
|
53
|
+
MonoLinesHighlighter, ReplaceGenericHighlighter, PathHighlighter
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
prop = JsonSchemaDiff(
|
|
57
|
+
config=ConfigMaker.make(),
|
|
58
|
+
colorize_pipeline=HighlighterPipeline([
|
|
59
|
+
MonoLinesHighlighter(),
|
|
60
|
+
ReplaceGenericHighlighter(),
|
|
61
|
+
PathHighlighter(),
|
|
62
|
+
])
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
prop.compare(
|
|
66
|
+
old_schema="context.old.schema.json",
|
|
67
|
+
new_schema="context.new.schema.json"
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
prop.print(with_legend=True)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Output:**
|
|
74
|
+

|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
### CLI Usage
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Compare schema files
|
|
81
|
+
jsonschema-diff schema_v1.json schema_v2.json
|
|
82
|
+
|
|
83
|
+
# No colors (for logs/CI) and with exit-code
|
|
84
|
+
jsonschema-diff --no-color --exit-code schema_v1.json schema_v2.json
|
|
85
|
+
|
|
86
|
+
# Compare JSON strings
|
|
87
|
+
jsonschema-diff "{\"type\":\"string\"}" "{\"type\":\"number\"}"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
### Sphinx Extension
|
|
92
|
+
|
|
93
|
+
Use the extension in your build:
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
extensions += ["jsonschema_diff.sphinx"]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
You must also configure the extension. Add the following variable to your `conf.py`:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from jsonschema_diff import ConfigMaker, JsonSchemaDiff
|
|
103
|
+
from jsonschema_diff.color import HighlighterPipeline
|
|
104
|
+
from jsonschema_diff.color.stages import (
|
|
105
|
+
MonoLinesHighlighter, PathHighlighter, ReplaceGenericHighlighter,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
jsonschema_diff = JsonSchemaDiff(
|
|
109
|
+
config=ConfigMaker.make(),
|
|
110
|
+
colorize_pipeline=HighlighterPipeline(
|
|
111
|
+
[MonoLinesHighlighter(), ReplaceGenericHighlighter(), PathHighlighter()],
|
|
112
|
+
),
|
|
113
|
+
)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
After that, you can use it in your `.rst` files:
|
|
117
|
+
|
|
118
|
+
```rst
|
|
119
|
+
.. jsonschemadiff:: path/to/file.old.schema.json path/to/file.new.schema.json # from folder `source`
|
|
120
|
+
:name: filename.svg # optional
|
|
121
|
+
:title: Title in virtual terminal # optional
|
|
122
|
+
:no-legend: # optional
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
<div align="center">
|
|
127
|
+
|
|
128
|
+
## π Output Format
|
|
129
|
+
|
|
130
|
+
| Symbol | Meaning | Color | Example |
|
|
131
|
+
|--------|---------|-------|---------|
|
|
132
|
+
| `+` | Added | π’ Green | `+ ["new_field"].field: "string"` |
|
|
133
|
+
| `-` | Removed | π΄ Red | `- ["old_field"].field: "string"` |
|
|
134
|
+
| `r` | Changed | π΅ Cyan | `r ["field"].field: "old" -> "new"` |
|
|
135
|
+
| `m` | Modified | π΅ Cyan | `m ["field"]: ...` |
|
|
136
|
+
| ` ` | Context | βͺ None | ` ["related"]: "unchanged"` |
|
|
137
|
+
|
|
138
|
+
## ποΈ Architecture
|
|
139
|
+
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
Modern 6-stage pipeline for clean, testable code:
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
βββββββββββββββ βββββββββββββββββ ββββββββββββββββββββ
|
|
146
|
+
β DiffFinder βββββΆβ CompareFinder βββββΆβ CombineProcessor β
|
|
147
|
+
βββββββββββββββ βββββββββββββββββ ββββββββββββββββββββ
|
|
148
|
+
βΌ
|
|
149
|
+
βββββββββββββββ βββββββββββββββββ βββββββββββββββββ
|
|
150
|
+
β Formatter ββββββRenderProcessorββββββββ DiffProcessor β
|
|
151
|
+
βββββββββββββββ βββββββββββββββββ βββββββββββββββββ
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
1. **DiffFinder**: Finds raw differences
|
|
155
|
+
2. **CompareProcessor**: Find class-processors
|
|
156
|
+
3. **Combiner**: Combines related parameters
|
|
157
|
+
4. **RenderProcessor**: Adds context information and render
|
|
158
|
+
5. **Formatter**: Beautiful colored output
|
|
159
|
+
|
|
160
|
+
<div align="center">
|
|
161
|
+
|
|
162
|
+
## π οΈ Development
|
|
163
|
+
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
### Setup
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
git clone https://github.com/Miskler/jsonschema-diff.git
|
|
170
|
+
cd jsonschema-diff
|
|
171
|
+
python -m venv .venv
|
|
172
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
173
|
+
make build
|
|
174
|
+
make install-dev
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Commands
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Checks
|
|
181
|
+
make test # Run tests with coverage
|
|
182
|
+
make lint # Lint code
|
|
183
|
+
make type-check # Type checking
|
|
184
|
+
# Action
|
|
185
|
+
make format # Format code
|
|
186
|
+
make docs # Build documentation
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
<div align="center">
|
|
190
|
+
|
|
191
|
+
## π Documentation
|
|
192
|
+
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
- **[π Full Documentation](https://miskler.github.io/jsonschema-diff/)**
|
|
196
|
+
- **[π Quick Start Guide](https://miskler.github.io/jsonschema-diff/basic/quick_start/)**
|
|
197
|
+
- **[π§ API Reference](https://miskler.github.io/jsonschema-diff/reference/api/index.html)**
|
|
198
|
+
|
|
199
|
+
<div align="center">
|
|
200
|
+
|
|
201
|
+
## π€ Contributing
|
|
202
|
+
|
|
203
|
+
### ***We welcome contributions!***
|
|
204
|
+
|
|
205
|
+
### Quick Contribution Setup
|
|
206
|
+
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Fork the repo, then:
|
|
211
|
+
git clone https://github.com/your-username/jsonschema-diff.git
|
|
212
|
+
cd jsonschema-diff
|
|
213
|
+
# Install
|
|
214
|
+
make build
|
|
215
|
+
make install-dev
|
|
216
|
+
# Ensure everything works
|
|
217
|
+
make test
|
|
218
|
+
make lint
|
|
219
|
+
make type-check
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
<div align="center">
|
|
223
|
+
|
|
224
|
+
## π License
|
|
225
|
+
|
|
226
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
227
|
+
|
|
228
|
+
*Made with β€οΈ for developers working with evolving JSON schemas*
|
|
229
|
+
|
|
230
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from importlib import import_module
|
|
2
|
+
from types import ModuleType
|
|
3
|
+
|
|
4
|
+
from .config_maker import ConfigMaker
|
|
5
|
+
from .pypi_interface import JsonSchemaDiff
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Lazy-import ΠΏΠΎΠ΄ΠΌΠΎΠ΄ΡΠ»Ρ sphinx (ΡΡΠ½Π΅Ρ Rich β Sphinx ΡΠΎΠ»ΡΠΊΠΎ ΠΏΠΎ ΡΡΠ΅Π±ΠΎΠ²Π°Π½ΠΈΡ)
|
|
9
|
+
def __getattr__(name: str) -> ModuleType: # pragma: no cover
|
|
10
|
+
if name == "sphinx":
|
|
11
|
+
return import_module("jsonschema_diff.sphinx")
|
|
12
|
+
raise AttributeError(name)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
__all__ = ["JsonSchemaDiff", "ConfigMaker"]
|
|
16
|
+
|
|
17
|
+
__version__ = "0.1.0"
|