-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Bug Description
The JTD validator has incorrect logic for handling the default value of additionalProperties in PropertiesSchema.
Current (Incorrect) Behavior
In Jtd.java line 446, when both properties and optionalProperties are empty, the code sets additionalProperties = true. This means an empty properties schema like {} or {additionalProperties: false} allows any additional properties.
Expected (Correct) Behavior
According to RFC 8927, additionalProperties should default to false when properties or optionalProperties are defined. An empty properties schema should reject additional properties by default.
Test Case That Reveals the Bug
Schema: {elements: {properties: {}}}
This should reject additional properties but currently allows them
This document should FAIL validation but currently PASSES:
[{}, {extraProperty:extra-value}]
Code Location
File: json-java21-jtd/src/main/java/json/java21/jtd/Jtd.java
Lines: 436-446
The fix should change line 446 from:
additionalProperties = true;
to:
additionalProperties = false;
This ensures that empty properties schemas reject additional properties by default, which is the correct RFC 8927 behavior.