json-structure 0.1.21__tar.gz → 0.3.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: json-structure
3
- Version: 0.1.21
3
+ Version: 0.3.0
4
4
  Summary: Validators for JSON Structure schemas and instances
5
5
  Project-URL: Homepage, https://json-structure.org
6
6
  Project-URL: Documentation, https://github.com/json-structure/sdk
@@ -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.1.21'
32
- __version_tuple__ = version_tuple = (0, 1, 21)
31
+ __version__ = version = '0.3.0'
32
+ __version_tuple__ = version_tuple = (0, 3, 0)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -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 is a built-in property allowed in all instances
484
- reserved_props = {"$schema"}
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
- if key not in props and key not in reserved_props:
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
- if key not in props and key not in reserved_props:
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: