Skip to content

Commit cf16f71

Browse files
committed
Issue #91 Fix additionalProperties default value in JTD validator
- Fixed JTD validator to correctly default additionalProperties to false when no properties are defined - Added test case testAdditionalPropertiesDefaultsToFalse() to verify the fix - Updated CI test count from 463 to 464 to account for new test - This ensures RFC 8927 compliance where empty properties schemas reject additional properties by default The bug was in Jtd.java line 446 where additionalProperties was set to true instead of false when both properties and optionalProperties were empty. This caused empty schemas to incorrectly allow additional properties instead of rejecting them by default. Closes #91
1 parent d4fd468 commit cf16f71

File tree

4 files changed

+500
-3
lines changed

4 files changed

+500
-3
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
for k in totals: totals[k]+=int(r.get(k,'0'))
4040
except Exception:
4141
pass
42-
exp_tests=463
42+
exp_tests=464
4343
exp_skipped=0
4444
if totals['tests']!=exp_tests or totals['skipped']!=exp_skipped:
4545
print(f"Unexpected test totals: {totals} != expected tests={exp_tests}, skipped={exp_skipped}")

json-java21-jtd/src/main/java/json/java21/jtd/Jtd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ JtdSchema compilePropertiesSchema(JsonObject obj) {
442442
}
443443
additionalProperties = bool.value();
444444
} else if (properties.isEmpty() && optionalProperties.isEmpty()) {
445-
// Empty schema with no properties defined allows additional properties by default
446-
additionalProperties = true;
445+
// Empty schema with no properties defined rejects additional properties by default
446+
additionalProperties = false;
447447
}
448448

449449
return new JtdSchema.PropertiesSchema(properties, optionalProperties, additionalProperties);

0 commit comments

Comments
 (0)