Skip to content

Commit a3c2e97

Browse files
authored
Merge pull request #4 from networknt/master
Merging Changes from networknt repo.
2 parents a04a1fa + 03bf8ef commit a3c2e97

File tree

5 files changed

+106
-7
lines changed

5 files changed

+106
-7
lines changed

pom.xml

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@
6363
<java.testversion>1.8</java.testversion>
6464
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
6565
<version.jackson>2.10.4</version.jackson>
66-
<version.slf4j>1.7.25</version.slf4j>
67-
<version.common-lang3>3.5</version.common-lang3>
66+
<version.slf4j>1.7.30</version.slf4j>
67+
<version.common-lang3>3.7</version.common-lang3>
6868
<version.joni>2.1.31</version.joni>
6969
<version.logback>1.2.3</version.logback>
70-
<version.junit>4.12</version.junit>
70+
<version.junit>4.13.1</version.junit>
7171
<version.mockito>2.7.21</version.mockito>
7272
<version.hamcrest>1.3</version.hamcrest>
7373
<version.undertow>2.1.3.Final</version.undertow>
@@ -91,6 +91,7 @@
9191
<dependency>
9292
<groupId>org.jruby.joni</groupId>
9393
<artifactId>joni</artifactId>
94+
<optional>true</optional>
9495
<version>${version.joni}</version>
9596
</dependency>
9697
<dependency>
@@ -163,6 +164,39 @@
163164
</instructions>
164165
</configuration>
165166
</plugin>
167+
<plugin>
168+
<groupId>org.moditect</groupId>
169+
<artifactId>moditect-maven-plugin</artifactId>
170+
<version>1.0.0.RC1</version>
171+
<executions>
172+
<execution>
173+
<id>add-module-info</id>
174+
<phase>package</phase>
175+
<goals>
176+
<goal>add-module-info</goal>
177+
</goals>
178+
<configuration>
179+
<jvmVersion>9</jvmVersion>
180+
<module>
181+
<moduleInfoSource>
182+
module com.networknt.schema {
183+
requires transitive com.fasterxml.jackson.databind;
184+
requires org.apache.commons.lang3;
185+
requires org.jruby.jcodings;
186+
requires org.jruby.joni;
187+
requires org.slf4j;
188+
189+
exports com.networknt.schema;
190+
exports com.networknt.schema.format;
191+
exports com.networknt.schema.uri;
192+
exports com.networknt.schema.urn;
193+
}
194+
</moduleInfoSource>
195+
</module>
196+
</configuration>
197+
</execution>
198+
</executions>
199+
</plugin>
166200
<plugin>
167201
<groupId>org.sonatype.plugins</groupId>
168202
<artifactId>nexus-staging-maven-plugin</artifactId>
@@ -193,13 +227,16 @@
193227
<plugin>
194228
<groupId>org.apache.maven.plugins</groupId>
195229
<artifactId>maven-javadoc-plugin</artifactId>
196-
<version>2.10.4</version>
230+
<version>3.2.0</version>
197231
<executions>
198232
<execution>
199233
<id>attach-javadocs</id>
200234
<goals>
201235
<goal>jar</goal>
202236
</goals>
237+
<configuration>
238+
<source>8</source>
239+
</configuration>
203240
</execution>
204241
</executions>
205242
</plugin>
@@ -243,7 +280,7 @@
243280
<plugin>
244281
<groupId>org.jacoco</groupId>
245282
<artifactId>jacoco-maven-plugin</artifactId>
246-
<version>0.7.9</version>
283+
<version>0.8.6</version>
247284
<executions>
248285
<execution>
249286
<id>pre-unit-test</id>
@@ -311,7 +348,7 @@
311348
<plugin>
312349
<groupId>org.jacoco</groupId>
313350
<artifactId>jacoco-maven-plugin</artifactId>
314-
<version>0.7.9</version>
351+
<version>0.8.6</version>
315352
<executions>
316353
<!-- The Executions for merging -->
317354
<execution>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ public static JsonMetaSchema getInstance() {
141141
new NonValidationKeyword("title"),
142142
new NonValidationKeyword("description"),
143143
new NonValidationKeyword("default"),
144-
new NonValidationKeyword("definitions")
144+
new NonValidationKeyword("definitions"),
145+
new NonValidationKeyword("$comment")
145146
))
146147
.build();
147148
}
@@ -171,6 +172,7 @@ public static JsonMetaSchema getInstance() {
171172
new NonValidationKeyword("description"),
172173
new NonValidationKeyword("default"),
173174
new NonValidationKeyword("definitions"),
175+
new NonValidationKeyword("$comment"),
174176
new NonValidationKeyword("$defs") // newly added in 2018-09 release.
175177
))
176178
.build();
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.networknt.schema;
2+
3+
import com.fasterxml.jackson.databind.JsonNode;
4+
import com.fasterxml.jackson.databind.ObjectMapper;
5+
import org.junit.Assert;
6+
import org.junit.Test;
7+
8+
import java.io.InputStream;
9+
import java.util.Set;
10+
11+
public class Issue327Test {
12+
protected JsonSchema getJsonSchemaFromStreamContentV7(InputStream schemaContent) {
13+
JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7);
14+
return factory.getSchema(schemaContent);
15+
}
16+
17+
protected JsonNode getJsonNodeFromStreamContent(InputStream content) throws Exception {
18+
ObjectMapper mapper = new ObjectMapper();
19+
JsonNode node = mapper.readTree(content);
20+
return node;
21+
}
22+
23+
@Test
24+
public void shouldWorkV7() throws Exception {
25+
String schemaPath = "/schema/issue327-v7.json";
26+
String dataPath = "/data/issue327.json";
27+
InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath);
28+
JsonSchema schema = getJsonSchemaFromStreamContentV7(schemaInputStream);
29+
InputStream dataInputStream = getClass().getResourceAsStream(dataPath);
30+
JsonNode node = getJsonNodeFromStreamContent(dataInputStream);
31+
Set<ValidationMessage> errors = schema.validate(node);
32+
Assert.assertEquals(0, errors.size());
33+
}
34+
}

src/test/resources/data/issue327.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"firstName": "John",
3+
"lastName": "Doe",
4+
"age": 21
5+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$id": "https://example.com/person.schema.json",
3+
"$schema": "http://json-schema.org/draft-07/schema#",
4+
"title": "Person",
5+
"type": "object",
6+
"properties": {
7+
"firstName": {
8+
"type": "string",
9+
"description": "The person's first name."
10+
},
11+
"lastName": {
12+
"type": "string",
13+
"description": "The person's last name."
14+
},
15+
"age": {
16+
"description": "Age in years which must be equal to or greater than zero.",
17+
"type": "integer",
18+
"minimum": 0
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)