Skip to content

Commit e2618a0

Browse files
authored
Merge pull request #142 from pipobscure/refOnly
When $ref is present other keywords should be ignored
2 parents f3d5aeb + b24fae2 commit e2618a0

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

tests/draft3/ref.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,39 @@
140140
}
141141
]
142142
},
143+
{
144+
"description": "ref overrides any sibling keywords",
145+
"schema": {
146+
"definitions": {
147+
"reffed": {
148+
"type": "array"
149+
}
150+
},
151+
"properties": {
152+
"foo": {
153+
"$ref": "#/definitions/reffed",
154+
"maxItems": 2
155+
}
156+
}
157+
},
158+
"tests": [
159+
{
160+
"description": "remote ref valid",
161+
"data": { "foo": [] },
162+
"valid": true
163+
},
164+
{
165+
"description": "remote ref valid, maxItems ignored",
166+
"data": { "foo": [ 1, 2, 3] },
167+
"valid": true
168+
},
169+
{
170+
"description": "ref invalid",
171+
"data": { "foo": "string" },
172+
"valid": false
173+
}
174+
]
175+
},
143176
{
144177
"description": "remote ref, containing refs itself",
145178
"schema": {"$ref": "http://json-schema.org/draft-03/schema#"},

tests/draft4/ref.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,39 @@
140140
}
141141
]
142142
},
143+
{
144+
"description": "ref overrides any sibling keywords",
145+
"schema": {
146+
"definitions": {
147+
"reffed": {
148+
"type": "array"
149+
}
150+
},
151+
"properties": {
152+
"foo": {
153+
"$ref": "#/definitions/reffed",
154+
"maxItems": 2
155+
}
156+
}
157+
},
158+
"tests": [
159+
{
160+
"description": "ref valid",
161+
"data": { "foo": [] },
162+
"valid": true
163+
},
164+
{
165+
"description": "ref valid, maxItems ignored",
166+
"data": { "foo": [ 1, 2, 3] },
167+
"valid": true
168+
},
169+
{
170+
"description": "ref invalid",
171+
"data": { "foo": "string" },
172+
"valid": false
173+
}
174+
]
175+
},
143176
{
144177
"description": "remote ref, containing refs itself",
145178
"schema": {"$ref": "http://json-schema.org/draft-04/schema#"},

0 commit comments

Comments
 (0)