json-structure 0.1.20__tar.gz → 0.2.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.
- {json_structure-0.1.20 → json_structure-0.2.0}/PKG-INFO +1 -1
- {json_structure-0.1.20 → json_structure-0.2.0}/src/json_structure/__init__.py +0 -2
- {json_structure-0.1.20 → json_structure-0.2.0}/src/json_structure/_version.py +2 -2
- {json_structure-0.1.20 → json_structure-0.2.0}/src/json_structure/error_codes.py +0 -4
- {json_structure-0.1.20 → json_structure-0.2.0}/src/json_structure/instance_validator.py +8 -4
- {json_structure-0.1.20 → json_structure-0.2.0}/.gitignore +0 -0
- {json_structure-0.1.20 → json_structure-0.2.0}/README.md +0 -0
- {json_structure-0.1.20 → json_structure-0.2.0}/pyproject.toml +0 -0
- {json_structure-0.1.20 → json_structure-0.2.0}/src/json_structure/json_source_locator.py +0 -0
- {json_structure-0.1.20 → json_structure-0.2.0}/src/json_structure/schema_exporter.py +0 -0
- {json_structure-0.1.20 → json_structure-0.2.0}/src/json_structure/schema_validator.py +0 -0
|
@@ -40,7 +40,6 @@ from json_structure.error_codes import (
|
|
|
40
40
|
SCHEMA_TUPLE_ORDER_NOT_ARRAY,
|
|
41
41
|
SCHEMA_MAP_MISSING_VALUES,
|
|
42
42
|
SCHEMA_CHOICE_MISSING_CHOICES,
|
|
43
|
-
SCHEMA_OPTIONS_NOT_OBJECT,
|
|
44
43
|
SCHEMA_CHOICES_NOT_OBJECT,
|
|
45
44
|
SCHEMA_PATTERN_INVALID,
|
|
46
45
|
SCHEMA_PATTERN_NOT_STRING,
|
|
@@ -201,7 +200,6 @@ __all__ = [
|
|
|
201
200
|
"SCHEMA_TUPLE_ORDER_NOT_ARRAY",
|
|
202
201
|
"SCHEMA_MAP_MISSING_VALUES",
|
|
203
202
|
"SCHEMA_CHOICE_MISSING_CHOICES",
|
|
204
|
-
"SCHEMA_OPTIONS_NOT_OBJECT",
|
|
205
203
|
"SCHEMA_CHOICES_NOT_OBJECT",
|
|
206
204
|
"SCHEMA_PATTERN_INVALID",
|
|
207
205
|
"SCHEMA_PATTERN_NOT_STRING",
|
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '0.
|
|
32
|
-
__version_tuple__ = version_tuple = (0,
|
|
31
|
+
__version__ = version = '0.2.0'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 2, 0)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
|
@@ -168,9 +168,6 @@ SCHEMA_MAP_MISSING_VALUES = "SCHEMA_MAP_MISSING_VALUES"
|
|
|
168
168
|
SCHEMA_CHOICE_MISSING_CHOICES = "SCHEMA_CHOICE_MISSING_CHOICES"
|
|
169
169
|
"""Choice type requires 'choices' keyword."""
|
|
170
170
|
|
|
171
|
-
SCHEMA_OPTIONS_NOT_OBJECT = "SCHEMA_OPTIONS_NOT_OBJECT"
|
|
172
|
-
"""Options must be an object."""
|
|
173
|
-
|
|
174
171
|
SCHEMA_CHOICES_NOT_OBJECT = "SCHEMA_CHOICES_NOT_OBJECT"
|
|
175
172
|
"""Choices must be an object."""
|
|
176
173
|
|
|
@@ -530,7 +527,6 @@ ERROR_CODES = {
|
|
|
530
527
|
"SCHEMA_TUPLE_ORDER_NOT_ARRAY": SCHEMA_TUPLE_ORDER_NOT_ARRAY,
|
|
531
528
|
"SCHEMA_MAP_MISSING_VALUES": SCHEMA_MAP_MISSING_VALUES,
|
|
532
529
|
"SCHEMA_CHOICE_MISSING_CHOICES": SCHEMA_CHOICE_MISSING_CHOICES,
|
|
533
|
-
"SCHEMA_OPTIONS_NOT_OBJECT": SCHEMA_OPTIONS_NOT_OBJECT,
|
|
534
530
|
"SCHEMA_CHOICES_NOT_OBJECT": SCHEMA_CHOICES_NOT_OBJECT,
|
|
535
531
|
"SCHEMA_PATTERN_INVALID": SCHEMA_PATTERN_INVALID,
|
|
536
532
|
"SCHEMA_PATTERN_NOT_STRING": SCHEMA_PATTERN_NOT_STRING,
|
|
@@ -480,15 +480,19 @@ class JSONStructureInstanceValidator:
|
|
|
480
480
|
self.validate_instance(instance[prop], prop_schema, f"{path}/{prop}")
|
|
481
481
|
if "additionalProperties" in schema:
|
|
482
482
|
addl = schema["additionalProperties"]
|
|
483
|
-
# $schema
|
|
484
|
-
|
|
483
|
+
# $schema and $uses are reserved properties allowed in instances at root level
|
|
484
|
+
reserved_instance_props = {"$schema", "$uses"}
|
|
485
485
|
if addl is False:
|
|
486
486
|
for key in instance.keys():
|
|
487
|
-
|
|
487
|
+
# Only allow reserved instance props at root level (path == '#')
|
|
488
|
+
is_reserved_at_root = path == "#" and key in reserved_instance_props
|
|
489
|
+
if key not in props and not is_reserved_at_root:
|
|
488
490
|
self.errors.append(f"Additional property '{key}' not allowed at {path}")
|
|
489
491
|
elif isinstance(addl, dict):
|
|
490
492
|
for key in instance.keys():
|
|
491
|
-
|
|
493
|
+
# Only allow reserved instance props at root level (path == '#')
|
|
494
|
+
is_reserved_at_root = path == "#" and key in reserved_instance_props
|
|
495
|
+
if key not in props and not is_reserved_at_root:
|
|
492
496
|
self.validate_instance(instance[key], addl, f"{path}/{key}")
|
|
493
497
|
# Extended object constraint: "has" keyword. [Metaschema: ObjectValidationAddIn]
|
|
494
498
|
if "has" in schema:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|