Skip to content

Commit f841582

Browse files
authored
Merge pull request #320 from pan3793/317
Follow up(#317) Compatible with Jackson 2.9.x
2 parents 5d8e6ac + 924d95f commit f841582

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/main/java/com/networknt/schema/PropertyNamesValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String
6161
}
6262
}
6363
} else {
64-
if(!schemaValue && node.isObject() && !node.isEmpty()) {
64+
if(!schemaValue && node.isObject() && node.size() != 0) {
6565
errors.add(buildValidationMessage(at + "." + node, "false"));
6666
}
6767
}

src/test/java/com/networknt/schema/Issue285Test.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.junit.Ignore;
66
import org.junit.Test;
77

8+
import java.io.IOException;
89
import java.net.URI;
910
import java.net.URISyntaxException;
1011
import java.util.Arrays;
@@ -52,7 +53,7 @@ public class Issue285Test {
5253
// In this case the "lastName" should be a string.
5354
// The result is as expected and we get an validation error.
5455
@Test
55-
public void nestedValidation() throws JsonProcessingException {
56+
public void nestedValidation() throws IOException {
5657
JsonSchema jsonSchema = schemaFactory.getSchema(schemaStr);
5758
Set<ValidationMessage> validationMessages = jsonSchema.validate(mapper.readTree(person));
5859

@@ -93,7 +94,7 @@ public void nestedValidation() throws JsonProcessingException {
9394
// The result is not as expected and we get no validation error.
9495
@Test
9596
@Ignore
96-
public void nestedTypeValidation() throws JsonProcessingException, URISyntaxException {
97+
public void nestedTypeValidation() throws IOException, URISyntaxException {
9798
URI uri = new URI("https://json-schema.org/draft/2019-09/schema");
9899
JsonSchema jsonSchema = schemaFactory.getSchema(uri);
99100
Set<ValidationMessage> validationMessages = jsonSchema.validate(mapper.readTree(invalidNestedSchema));
@@ -116,7 +117,7 @@ public void nestedTypeValidation() throws JsonProcessingException, URISyntaxExce
116117
// In this case the toplevel type declaration isn't valid and should raise an error.
117118
// The result is as expected and we get no validation error: '[$.type: does not have a value in the enumeration [array, boolean, integer, null, number, object, string], $.type: should be valid to any of the schemas array]'.
118119
@Test
119-
public void typeValidation() throws JsonProcessingException, URISyntaxException {
120+
public void typeValidation() throws IOException, URISyntaxException {
120121
URI uri = new URI("https://json-schema.org/draft/2019-09/schema");
121122
JsonSchema jsonSchema = schemaFactory.getSchema(uri);
122123
Set<ValidationMessage> validationMessages = jsonSchema.validate(mapper.readTree(invalidSchema));

0 commit comments

Comments
 (0)