Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
for k in totals: totals[k]+=int(r.get(k,'0'))
except Exception:
pass
exp_tests=465
exp_tests=466
exp_skipped=0
if totals['tests']!=exp_tests or totals['skipped']!=exp_skipped:
print(f"Unexpected test totals: {totals} != expected tests={exp_tests}, skipped={exp_skipped}")
Expand Down
45 changes: 45 additions & 0 deletions json-java21-jtd/src/test/java/json/java21/jtd/TestRfc8927.java
Original file line number Diff line number Diff line change
Expand Up @@ -595,4 +595,49 @@ public void testDiscriminatorInElementsSchema() throws Exception {
.as("Discriminator in elements schema should validate the property test case")
.isTrue();
}

/// Test case from JtdExhaustiveTest property test failure
/// Nested elements containing properties schemas should reject additional properties
/// Schema: {"elements":{"elements":{"properties":{}}}}
/// Document: [[{},{},[{},{extraProperty":"extra-value"}]]
/// This should fail validation but currently passes incorrectly
@Test
public void testNestedElementsPropertiesRejectsAdditionalProperties() throws Exception {
JsonValue schema = Json.parse("""
{
"elements": {
"elements": {
"properties": {}
}
}
}
""");
JsonValue document = Json.parse("""
[
[{}, {}],
[{}, {"extraProperty": "extra-value"}]
]
""");

LOG.info(() -> "Testing nested elements properties - property test failure case");
LOG.fine(() -> "Schema: " + schema);
LOG.fine(() -> "Document: " + document);

Jtd validator = new Jtd();
Jtd.Result result = validator.validate(schema, document);

LOG.fine(() -> "Validation result: " + (result.isValid() ? "VALID" : "INVALID"));
if (!result.isValid()) {
LOG.fine(() -> "Errors: " + result.errors());
}

// This should fail because the inner object has an extra property
// and the properties schema should reject additional properties by default
assertThat(result.isValid())
.as("Nested elements properties should reject additional properties")
.isFalse();
assertThat(result.errors())
.as("Should have validation errors for additional property")
.isNotEmpty();
}
}