Skip to content

Commit 6c303ca

Browse files
committed
Merge pull request #38 from gazpachoking/array_pointers
Add a test for $refs with json pointers into arrays
2 parents 83f8e7f + 2a07823 commit 6c303ca

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

tests/draft3/ref.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
]
3232
},
3333
{
34-
"description": "relative pointer ref",
34+
"description": "relative pointer ref to object",
3535
"schema": {
3636
"properties": {
3737
"foo": {"type": "integer"},
@@ -51,6 +51,27 @@
5151
}
5252
]
5353
},
54+
{
55+
"description": "relative pointer ref to array",
56+
"schema": {
57+
"items": [
58+
{"type": "integer"},
59+
{"$ref": "#/items/0"}
60+
]
61+
},
62+
"tests": [
63+
{
64+
"description": "match array",
65+
"data": [1, 2],
66+
"valid": true
67+
},
68+
{
69+
"description": "mismatch array",
70+
"data": [1, "foo"],
71+
"valid": false
72+
}
73+
]
74+
},
5475
{
5576
"description": "escaped pointer ref",
5677
"schema": {

tests/draft4/ref.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
]
3232
},
3333
{
34-
"description": "relative pointer ref",
34+
"description": "relative pointer ref to object",
3535
"schema": {
3636
"properties": {
3737
"foo": {"type": "integer"},
@@ -51,6 +51,27 @@
5151
}
5252
]
5353
},
54+
{
55+
"description": "relative pointer ref to array",
56+
"schema": {
57+
"items": [
58+
{"type": "integer"},
59+
{"$ref": "#/items/0"}
60+
]
61+
},
62+
"tests": [
63+
{
64+
"description": "match array",
65+
"data": [1, 2],
66+
"valid": true
67+
},
68+
{
69+
"description": "mismatch array",
70+
"data": [1, "foo"],
71+
"valid": false
72+
}
73+
]
74+
},
5475
{
5576
"description": "escaped pointer ref",
5677
"schema": {

0 commit comments

Comments
 (0)