Skip to content

Commit

Permalink
Squashed 'json/' changes from 689d2f28..0f344a69
Browse files Browse the repository at this point in the history
0f344a69 Merge pull request #313 from leadpony/issue309
46c44747 Replace the control escape \\a with \\t
1ffe03e5 Merge pull request #312 from gregsdennis/master
de004798 better descripttions
eea7f249 arrays have characters too
7c02d06d added unevaluatedProperties test file; resolves #310
1899a5aa Merge pull request #308 from aznan2/master
4a5010b3 Update the version list.
37569b13 issue #307 - made test compatible with draft4
e3087307 issue #307 - removed issue reference from description
e13d3275 issue #307 - removed pound sign from description
a3b9f723 issue #307 - test that oneOf handles missing optional property

git-subtree-dir: json
git-subtree-split: 0f344a698f6657441adf4ebf4ceeacd596683422
  • Loading branch information
Julian committed Nov 29, 2019
1 parent a40ce64 commit 5195dd8
Show file tree
Hide file tree
Showing 10 changed files with 227 additions and 20 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ they should be valid or invalid.
Coverage
--------

Drafts 03, 04, 06, and 07 should have full coverage, with drafts 06 and 07
being considered current and actively supported. Bug fixes will be made as
needed for draft-04 as it is still the most widely used, while draft-03
is long since deprecated.
Drafts 07, 06, 04 and 03 should have full coverage, with drafts 06 and
07 being considered current and actively supported.

Draft 2019-09 support is under development. Contributions are very
welcome, especially from implementers as they add support to their own
implementations.

Bug fixes will be made as needed for draft-04 as it is still the most
widely used, while draft-03 is long since deprecated.

If you see anything missing from the current supported drafts, or incorrect
on any draft still accepting bug fixes, please file an issue or submit a PR.
Expand Down
42 changes: 42 additions & 0 deletions tests/draft2019-09/oneOf.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,47 @@
"valid": false
}
]
},
{
"description": "oneOf with missing optional property",
"schema": {
"oneOf": [
{
"properties": {
"bar": true,
"baz": true
},
"required": ["bar"]
},
{
"properties": {
"foo": true
},
"required": ["foo"]
}
]
},
"tests": [
{
"description": "first oneOf valid",
"data": {"bar": 8},
"valid": true
},
{
"description": "second oneOf valid",
"data": {"foo": "foo"},
"valid": true
},
{
"description": "both oneOf valid",
"data": {"foo": "foo", "bar": 8},
"valid": false
},
{
"description": "neither oneOf valid",
"data": {"baz": "quux"},
"valid": false
}
]
}
]
8 changes: 4 additions & 4 deletions tests/draft2019-09/optional/ecmascript-regex.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@
]
},
{
"description": "ECMA 262 regex converts \\a to ascii BEL",
"description": "ECMA 262 regex converts \\t to horizontal tab",
"schema": {
"type": "string",
"pattern": "^\\a$"
"pattern": "^\\t$"
},
"tests": [
{
"description": "does not match",
"data": "\\a",
"data": "\\t",
"valid": false
},
{
"description": "matches",
"data": "\u0007",
"data": "\u0009",
"valid": true
}
]
Expand Down
34 changes: 34 additions & 0 deletions tests/draft2019-09/unevaluatedProperties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"description": "can peer inside allOf, results in no-op",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"unevaluatedProperties": false,
"allOf": [
{
"properties": {
"foo": { "type": ["string", "null"] },
"bar": { "type": ["string", "null"] }
}
},
{
"additionalProperties": {
"not": { "enum": [ null ] }
}
}
]
},
"tests": [
{
"description": "string props valid",
"data": { "bar": "foo", "bob": "who?" },
"valid": true
},
{
"description": "null prop is invalid",
"data": { "bar": "foo", "bob": null },
"valid": false
}
]
}
]
42 changes: 42 additions & 0 deletions tests/draft4/oneOf.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,47 @@
"valid": false
}
]
},
{
"description": "oneOf with missing optional property",
"schema": {
"oneOf": [
{
"properties": {
"bar": {},
"baz": {}
},
"required": ["bar"]
},
{
"properties": {
"foo": {}
},
"required": ["foo"]
}
]
},
"tests": [
{
"description": "first oneOf valid",
"data": {"bar": 8},
"valid": true
},
{
"description": "second oneOf valid",
"data": {"foo": "foo"},
"valid": true
},
{
"description": "both oneOf valid",
"data": {"foo": "foo", "bar": 8},
"valid": false
},
{
"description": "neither oneOf valid",
"data": {"baz": "quux"},
"valid": false
}
]
}
]
8 changes: 4 additions & 4 deletions tests/draft4/optional/ecmascript-regex.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@
]
},
{
"description": "ECMA 262 regex converts \\a to ascii BEL",
"description": "ECMA 262 regex converts \\t to horizontal tab",
"schema": {
"type": "string",
"pattern": "^\\a$"
"pattern": "^\\t$"
},
"tests": [
{
"description": "does not match",
"data": "\\a",
"data": "\\t",
"valid": false
},
{
"description": "matches",
"data": "\u0007",
"data": "\u0009",
"valid": true
}
]
Expand Down
42 changes: 42 additions & 0 deletions tests/draft6/oneOf.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,47 @@
"valid": false
}
]
},
{
"description": "oneOf with missing optional property",
"schema": {
"oneOf": [
{
"properties": {
"bar": true,
"baz": true
},
"required": ["bar"]
},
{
"properties": {
"foo": true
},
"required": ["foo"]
}
]
},
"tests": [
{
"description": "first oneOf valid",
"data": {"bar": 8},
"valid": true
},
{
"description": "second oneOf valid",
"data": {"foo": "foo"},
"valid": true
},
{
"description": "both oneOf valid",
"data": {"foo": "foo", "bar": 8},
"valid": false
},
{
"description": "neither oneOf valid",
"data": {"baz": "quux"},
"valid": false
}
]
}
]
8 changes: 4 additions & 4 deletions tests/draft6/optional/ecmascript-regex.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@
]
},
{
"description": "ECMA 262 regex converts \\a to ascii BEL",
"description": "ECMA 262 regex converts \\t to horizontal tab",
"schema": {
"type": "string",
"pattern": "^\\a$"
"pattern": "^\\t$"
},
"tests": [
{
"description": "does not match",
"data": "\\a",
"data": "\\t",
"valid": false
},
{
"description": "matches",
"data": "\u0007",
"data": "\u0009",
"valid": true
}
]
Expand Down
42 changes: 42 additions & 0 deletions tests/draft7/oneOf.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,47 @@
"valid": false
}
]
},
{
"description": "oneOf with missing optional property",
"schema": {
"oneOf": [
{
"properties": {
"bar": true,
"baz": true
},
"required": ["bar"]
},
{
"properties": {
"foo": true
},
"required": ["foo"]
}
]
},
"tests": [
{
"description": "first oneOf valid",
"data": {"bar": 8},
"valid": true
},
{
"description": "second oneOf valid",
"data": {"foo": "foo"},
"valid": true
},
{
"description": "both oneOf valid",
"data": {"foo": "foo", "bar": 8},
"valid": false
},
{
"description": "neither oneOf valid",
"data": {"baz": "quux"},
"valid": false
}
]
}
]
8 changes: 4 additions & 4 deletions tests/draft7/optional/ecmascript-regex.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@
]
},
{
"description": "ECMA 262 regex converts \\a to ascii BEL",
"description": "ECMA 262 regex converts \\t to horizontal tab",
"schema": {
"type": "string",
"pattern": "^\\a$"
"pattern": "^\\t$"
},
"tests": [
{
"description": "does not match",
"data": "\\a",
"data": "\\t",
"valid": false
},
{
"description": "matches",
"data": "\u0007",
"data": "\u0009",
"valid": true
}
]
Expand Down

0 comments on commit 5195dd8

Please sign in to comment.