Skip to content

Commit 6a3b90d

Browse files
authored
Merge pull request #3 from networknt/master
Getting latest changes from networknt
2 parents 8f42eac + e0e1b02 commit 6a3b90d

File tree

10 files changed

+28
-16
lines changed

10 files changed

+28
-16
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Changed
1111

12+
## 1.0.43 - 2020-08-10
13+
14+
### Added
15+
16+
### Changed
17+
18+
- fixes #317 Compatible with Jackson 2.9.x. Thanks @pan3793
19+
- fixes #315 implement propertyNames validator for v6, v7 and v2019-09
20+
1221
## 1.0.42 - 2020-06-30
1322

1423
### Added

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ Maven:
8282
<dependency>
8383
<groupId>com.networknt</groupId>
8484
<artifactId>json-schema-validator</artifactId>
85-
<version>1.0.42</version>
85+
<version>1.0.43</version>
8686
</dependency>
8787
```
8888

8989
Gradle:
9090

9191
```
9292
dependencies {
93-
compile(group: "com.networknt", name: "json-schema-validator", version: "1.0.42");
93+
compile(group: "com.networknt", name: "json-schema-validator", version: "1.0.43");
9494
}
9595
```
9696

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<modelVersion>4.0.0</modelVersion>
2121
<groupId>com.networknt</groupId>
2222
<artifactId>json-schema-validator</artifactId>
23-
<version>1.0.42</version>
23+
<version>1.0.43</version>
2424
<packaging>bundle</packaging>
2525
<description>A json schema validator that supports draft v4, v6, v7 and v2019-09</description>
2626
<url>https://github.com/networknt/json-schema-validator</url>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public Object get(String name) {
9292

9393
/**
9494
* Returns all the collected data. Please look into {@link #get(String)} method for more details.
95+
* @return Map
9596
*/
9697
public Map<String, Object> getAll() {
9798
Map<String, Object> mergedMap = new HashMap<String, Object>();

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String
4747
return Collections.emptySet();
4848
}
4949

50-
if (node.isEmpty()) {
50+
// to support jackson < 2.10
51+
if (node.size() == 0) {
5152
// Array was empty
5253
return buildErrorMessageSet(at);
5354
} else if (node.isArray()) {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,7 @@ public JsonValidator newValidator(ValidationContext validationContext, String sc
333333
try {
334334
Keyword kw = keywords.get(keyword);
335335
if (kw == null) {
336-
if (!UNKNOWN_KEYWORDS.containsKey(keyword)) {
337-
UNKNOWN_KEYWORDS.put(keyword, keyword);
336+
if (UNKNOWN_KEYWORDS.put(keyword, keyword) == null) {
338337
logger.warn("Unknown keyword " + keyword + " - you should define your own Meta Schema. If the keyword is irrelevant for validation, just use a NonValidationKeyword");
339338
}
340339
return null;

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/CollectorContextTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.junit.Before;
2424
import org.junit.Test;
2525

26+
import java.io.IOException;
2627
import java.util.*;
2728

2829
public class CollectorContextTest {
@@ -96,7 +97,7 @@ public void testCollectorContextWithMultiplThreads() throws Exception {
9697

9798
@SuppressWarnings("unchecked")
9899
@Test
99-
public void testCollectorWithFormat() throws JsonMappingException, JsonProcessingException {
100+
public void testCollectorWithFormat() throws JsonMappingException, JsonProcessingException, IOException {
100101
ObjectMapper objectMapper = new ObjectMapper();
101102
ValidationResult validationResult = jsonSchemaForCombine.validateAndCollect(objectMapper
102103
.readTree("{\"property1\":\"sample1\",\"property2\":\"sample2\",\"property3\":\"sample3\" }"));
@@ -108,7 +109,7 @@ public void testCollectorWithFormat() throws JsonMappingException, JsonProcessin
108109

109110
@SuppressWarnings("unchecked")
110111
@Test
111-
public void testCollectorGetAll() throws JsonMappingException, JsonProcessingException {
112+
public void testCollectorGetAll() throws JsonMappingException, JsonProcessingException, IOException {
112113
ObjectMapper objectMapper = new ObjectMapper();
113114
ValidationResult validationResult = jsonSchemaForCombine.validateAndCollect(objectMapper
114115
.readTree("{\"property1\":\"sample1\",\"property2\":\"sample2\",\"property3\":\"sample3\" }"));

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));

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.networknt.schema;
22

3-
import com.fasterxml.jackson.core.JsonProcessingException;
43
import com.fasterxml.jackson.databind.JsonNode;
54
import com.fasterxml.jackson.databind.ObjectMapper;
65
import org.junit.Assert;
76
import org.junit.Test;
87

8+
import java.io.IOException;
99
import java.util.Set;
1010

1111
public class UnknownMetaSchemaTest {
@@ -17,7 +17,7 @@ public class UnknownMetaSchemaTest {
1717
private String json = "{\"data\":1}";
1818

1919
@Test
20-
public void testSchema1() throws JsonProcessingException {
20+
public void testSchema1() throws IOException {
2121
ObjectMapper mapper = new ObjectMapper();
2222
JsonNode jsonNode = mapper.readTree(this.json);
2323

@@ -31,7 +31,7 @@ public void testSchema1() throws JsonProcessingException {
3131
}
3232

3333
@Test
34-
public void testSchema2() throws JsonProcessingException {
34+
public void testSchema2() throws IOException {
3535
ObjectMapper mapper = new ObjectMapper();
3636
JsonNode jsonNode = mapper.readTree(this.json);
3737

@@ -44,7 +44,7 @@ public void testSchema2() throws JsonProcessingException {
4444
}
4545
}
4646
@Test
47-
public void testSchema3() throws JsonProcessingException {
47+
public void testSchema3() throws IOException {
4848
ObjectMapper mapper = new ObjectMapper();
4949
JsonNode jsonNode = mapper.readTree(this.json);
5050

0 commit comments

Comments
 (0)