Skip to content

Commit 762db8f

Browse files
authored
Merge pull request #45 from escenic/master
Added test case for loading schemas from classpath
2 parents ae43a2e + fcc6e6a commit 762db8f

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,9 @@ public void testIdSchemaWithUrl() throws Exception {
274274
runTestFile("tests/id_schema/property.json");
275275
}
276276

277+
@Test
278+
public void testSchemaFromClasspath() throws Exception {
279+
runTestFile("tests/classpath/schema.json");
280+
}
281+
277282
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[
2+
{
3+
"description": "Sub schema in classpath",
4+
"schema": {
5+
"id": "classpath:/tests/classpath/sub-schema.json",
6+
"type": "object",
7+
"properties": {
8+
"features": {
9+
"$ref": "#/features"
10+
}
11+
},
12+
"additionalProperties": false
13+
},
14+
"tests": [
15+
{
16+
"data": {
17+
"features": 4
18+
},
19+
"valid": true
20+
},
21+
{
22+
"data": {
23+
"features": 4.0
24+
},
25+
"valid": false
26+
}
27+
]
28+
}
29+
]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"title": "features",
4+
"features": {
5+
"title": "integer feature",
6+
"type": "integer",
7+
"minimum": 1,
8+
"maximum": 99999
9+
}
10+
}

0 commit comments

Comments
 (0)