Skip to content

Commit 956a455

Browse files
committed
adding integ test for #217 and extending test infra to be able to explicitly specify spec version in tests
1 parent 111e785 commit 956a455

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

tests/src/test/java/org/everit/json/schema/IssueTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.everit.json.schema;
22

3+
import static java.util.Arrays.asList;
34
import static java.util.Objects.requireNonNull;
45
import static java.util.stream.Collectors.joining;
56

@@ -124,7 +125,18 @@ private void consumeValidatorConfig() {
124125
.forEach(entry -> loaderBuilder
125126
.addFormatValidator(entry.getKey(), this.createFormatValidator(entry)));
126127
});
127-
128+
configKeyHandlers.put("metaSchemaVersion", value -> {
129+
int versionNo = (Integer) value;
130+
if (!asList(4, 6, 7).contains(versionNo)) {
131+
throw new IllegalArgumentException(
132+
"invalid metaSchemaVersion in validator-config.json: should be one of 4, 6, or 7, found: " + versionNo);
133+
}
134+
if (versionNo == 6) {
135+
loaderBuilder.draftV6Support();
136+
} else if (versionNo == 7) {
137+
loaderBuilder.draftV7Support();
138+
}
139+
});
128140
fileByName("validator-config.json").map(file -> fileAsJson(file)).ifPresent(configJson -> {
129141
configKeyHandlers.entrySet()
130142
.stream()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "http://myschema.org/mymetaschema#",
3+
"$id": "http://myschema.org/myschema#",
4+
"title": "My schema",
5+
"description": "My schema",
6+
"properties": {
7+
"prop1": {
8+
"type": "string",
9+
"ext1": "xxx",
10+
"ext2": {
11+
"foo": "bar"
12+
}
13+
}
14+
}
15+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"prop1" : "foo"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"metaSchemaVersion": 7
3+
}

0 commit comments

Comments
 (0)