summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2021-04-28 09:33:03 -0400
committerJulian Berman <Julian@GrayVines.com>2021-04-28 09:33:03 -0400
commit783d81d5ef41ddda7681bd63f6fb7ce05ef3d8d8 (patch)
treecc4bd5ff399308db833c6d74721ebc9bb761e89f
parenta241799a5a5ffafaa93d6dd9b9cd8762e02525c6 (diff)
parentc19f0b4ee66ce10217185fa8d2c8b7a2784e3a31 (diff)
downloadjsonschema-783d81d5ef41ddda7681bd63f6fb7ce05ef3d8d8.tar.gz
Merge commit 'c19f0b4ee66ce10217185fa8d2c8b7a2784e3a31'
* commit 'c19f0b4ee66ce10217185fa8d2c8b7a2784e3a31': Squashed 'json/' changes from 15ec577f..09fd353f
-rw-r--r--json/README.md14
-rw-r--r--json/tests/draft2019-09/additionalItems.json23
-rw-r--r--json/tests/draft2019-09/default.json30
-rw-r--r--json/tests/draft2019-09/optional/format/time.json75
-rw-r--r--json/tests/draft2019-09/ref.json7
-rw-r--r--json/tests/draft2020-12/default.json30
-rw-r--r--json/tests/draft2020-12/items.json19
-rw-r--r--json/tests/draft2020-12/optional/format/time.json75
-rw-r--r--json/tests/draft2020-12/ref.json7
-rw-r--r--json/tests/draft2020-12/unevaluatedItems.json108
-rw-r--r--json/tests/draft3/additionalItems.json4
-rw-r--r--json/tests/draft3/default.json30
-rw-r--r--json/tests/draft3/ref.json2
-rw-r--r--json/tests/draft4/additionalItems.json23
-rw-r--r--json/tests/draft4/default.json30
-rw-r--r--json/tests/draft4/ref.json2
-rw-r--r--json/tests/draft6/additionalItems.json23
-rw-r--r--json/tests/draft6/default.json30
-rw-r--r--json/tests/draft6/id.json8
-rw-r--r--json/tests/draft6/ref.json7
-rw-r--r--json/tests/draft7/additionalItems.json23
-rw-r--r--json/tests/draft7/default.json30
-rw-r--r--json/tests/draft7/id.json8
-rw-r--r--json/tests/draft7/optional/format/time.json75
-rw-r--r--json/tests/draft7/ref.json7
25 files changed, 660 insertions, 30 deletions
diff --git a/json/README.md b/json/README.md
index b79b89a..63053d6 100644
--- a/json/README.md
+++ b/json/README.md
@@ -61,8 +61,8 @@ directory. This is:
## Coverage
Drafts 07, 06, 04, and 03 should have full coverage, with tests for drafts 06,
-07, and 2019-09 being considered current and actively supported. Draft 2019-09
-is almost fully covered.
+07, 2019-09 and 2020-12 being considered current and actively supported.
+Drafts 2019-09 and 2020-12 are almost fully covered.
Contributions are very welcome, especially from implementers as they add support
to their own implementations.
@@ -95,11 +95,11 @@ This suite is being used by:
### Dart
-* [json_schema](https://github.com/patefacio/json_schema)
+* [json\_schema](https://github.com/patefacio/json_schema)
### Elixir
-* [ex_json_schema](https://github.com/jonasschmidt/ex_json_schema)
+* [ex\_json\_schema](https://github.com/jonasschmidt/ex_json_schema)
### Erlang
@@ -159,17 +159,19 @@ which also welcomes your contributions!
### Perl
* [JSON::Schema::Draft201909](https://github.com/karenetheridge/JSON-Schema-Draft201909)
+* [JSON::Schema::Tiny](https://github.com/karenetheridge/JSON-Schema-Tiny)
* [Test::JSON::Schema::Acceptance](https://github.com/karenetheridge/Test-JSON-Schema-Acceptance)
### PHP
+* [opis/json-schema](https://github.com/opis/json-schema)
* [json-schema](https://github.com/justinrainbow/json-schema)
* [json-guard](https://github.com/thephpleague/json-guard)
### PostgreSQL
* [postgres-json-schema](https://github.com/gavinwahl/postgres-json-schema)
-* [is_jsonb_valid](https://github.com/furstenheim/is_jsonb_valid)
+* [is\_jsonb\_valid](https://github.com/furstenheim/is_jsonb_valid)
### Python
@@ -181,7 +183,7 @@ which also welcomes your contributions!
### Ruby
* [json-schema](https://github.com/hoxworth/json-schema)
-* [json_schemer](https://github.com/davishmcclurg/json_schemer)
+* [json\_schemer](https://github.com/davishmcclurg/json_schemer)
### Rust
diff --git a/json/tests/draft2019-09/additionalItems.json b/json/tests/draft2019-09/additionalItems.json
index ee46b61..784bc84 100644
--- a/json/tests/draft2019-09/additionalItems.json
+++ b/json/tests/draft2019-09/additionalItems.json
@@ -19,7 +19,7 @@
]
},
{
- "description": "items is schema, no additionalItems",
+ "description": "when items is schema, additionalItems does nothing",
"schema": {
"items": {},
"additionalItems": false
@@ -33,7 +33,7 @@
]
},
{
- "description": "array of items with no additionalItems",
+ "description": "array of items with no additionalItems permitted",
"schema": {
"items": [{}, {}, {}],
"additionalItems": false
@@ -126,5 +126,24 @@
"valid": false
}
]
+ },
+ {
+ "description": "items validation adjusts the starting index for additionalItems",
+ "schema": {
+ "items": [ { "type": "string" } ],
+ "additionalItems": { "type": "integer" }
+ },
+ "tests": [
+ {
+ "description": "valid items",
+ "data": [ "x", 2, 3 ],
+ "valid": true
+ },
+ {
+ "description": "wrong type of second item",
+ "data": [ "x", "y" ],
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/default.json b/json/tests/draft2019-09/default.json
index 1762977..289a9b6 100644
--- a/json/tests/draft2019-09/default.json
+++ b/json/tests/draft2019-09/default.json
@@ -45,5 +45,35 @@
"valid": true
}
]
+ },
+ {
+ "description": "the default keyword does not do anything if the property is missing",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "alpha": {
+ "type": "number",
+ "maximum": 3,
+ "default": 5
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "an explicit property value is checked against maximum (passing)",
+ "data": { "alpha": 1 },
+ "valid": true
+ },
+ {
+ "description": "an explicit property value is checked against maximum (failing)",
+ "data": { "alpha": 5 },
+ "valid": false
+ },
+ {
+ "description": "missing properties are not filled in with the default",
+ "data": {},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/optional/format/time.json b/json/tests/draft2019-09/optional/format/time.json
index 4ec8a01..74e8bf9 100644
--- a/json/tests/draft2019-09/optional/format/time.json
+++ b/json/tests/draft2019-09/optional/format/time.json
@@ -5,10 +5,85 @@
"tests": [
{
"description": "a valid time string",
+ "data": "08:30:06Z",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with leap second",
+ "data": "23:59:60Z",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with leap second with offset",
+ "data": "15:59:60-08:00",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with second fraction",
+ "data": "23:20:50.52Z",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with precise second fraction",
"data": "08:30:06.283185Z",
"valid": true
},
{
+ "description": "a valid time string with plus offset",
+ "data": "08:30:06+00:20",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with minus offset",
+ "data": "08:30:06-08:00",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with case-insensitive Z",
+ "data": "08:30:06z",
+ "valid": true
+ },
+ {
+ "description": "an invalid time string with invalid hour",
+ "data": "24:00:00Z",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid minute",
+ "data": "00:60:00Z",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid second",
+ "data": "00:00:61Z",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid leap second (wrong hour)",
+ "data": "22:59:60Z",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid leap second (wrong minute)",
+ "data": "23:58:60Z",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid time numoffset hour",
+ "data": "01:02:03+24:00",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid time numoffset minute",
+ "data": "01:02:03+00:60",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid time with both Z and numoffset",
+ "data": "01:02:03Z+00:30",
+ "valid": false
+ },
+ {
"description": "an invalid time string",
"data": "08:30:06 PST",
"valid": false
diff --git a/json/tests/draft2019-09/ref.json b/json/tests/draft2019-09/ref.json
index 2da81e3..71cf509 100644
--- a/json/tests/draft2019-09/ref.json
+++ b/json/tests/draft2019-09/ref.json
@@ -420,11 +420,16 @@
},
"tests": [
{
- "description": "do not evaluate the $ref inside the enum",
+ "description": "do not evaluate the $ref inside the enum, matching any string",
"data": "this is a string",
"valid": false
},
{
+ "description": "do not evaluate the $ref inside the enum, definition exact match",
+ "data": { "type": "string" },
+ "valid": false
+ },
+ {
"description": "match the enum exactly",
"data": { "$ref": "#/$defs/a_string" },
"valid": true
diff --git a/json/tests/draft2020-12/default.json b/json/tests/draft2020-12/default.json
index 1762977..289a9b6 100644
--- a/json/tests/draft2020-12/default.json
+++ b/json/tests/draft2020-12/default.json
@@ -45,5 +45,35 @@
"valid": true
}
]
+ },
+ {
+ "description": "the default keyword does not do anything if the property is missing",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "alpha": {
+ "type": "number",
+ "maximum": 3,
+ "default": 5
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "an explicit property value is checked against maximum (passing)",
+ "data": { "alpha": 1 },
+ "valid": true
+ },
+ {
+ "description": "an explicit property value is checked against maximum (failing)",
+ "data": { "alpha": 5 },
+ "valid": false
+ },
+ {
+ "description": "missing properties are not filled in with the default",
+ "data": {},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2020-12/items.json b/json/tests/draft2020-12/items.json
index 08a49ee..b918194 100644
--- a/json/tests/draft2020-12/items.json
+++ b/json/tests/draft2020-12/items.json
@@ -233,5 +233,24 @@
"valid": true
}
]
+ },
+ {
+ "description": "prefixItems validation adjusts the starting index for items",
+ "schema": {
+ "prefixItems": [ { "type": "string" } ],
+ "items": { "type": "integer" }
+ },
+ "tests": [
+ {
+ "description": "valid items",
+ "data": [ "x", 2, 3 ],
+ "valid": true
+ },
+ {
+ "description": "wrong type of second item",
+ "data": [ "x", "y" ],
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft2020-12/optional/format/time.json b/json/tests/draft2020-12/optional/format/time.json
index 4ec8a01..74e8bf9 100644
--- a/json/tests/draft2020-12/optional/format/time.json
+++ b/json/tests/draft2020-12/optional/format/time.json
@@ -5,10 +5,85 @@
"tests": [
{
"description": "a valid time string",
+ "data": "08:30:06Z",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with leap second",
+ "data": "23:59:60Z",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with leap second with offset",
+ "data": "15:59:60-08:00",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with second fraction",
+ "data": "23:20:50.52Z",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with precise second fraction",
"data": "08:30:06.283185Z",
"valid": true
},
{
+ "description": "a valid time string with plus offset",
+ "data": "08:30:06+00:20",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with minus offset",
+ "data": "08:30:06-08:00",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with case-insensitive Z",
+ "data": "08:30:06z",
+ "valid": true
+ },
+ {
+ "description": "an invalid time string with invalid hour",
+ "data": "24:00:00Z",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid minute",
+ "data": "00:60:00Z",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid second",
+ "data": "00:00:61Z",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid leap second (wrong hour)",
+ "data": "22:59:60Z",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid leap second (wrong minute)",
+ "data": "23:58:60Z",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid time numoffset hour",
+ "data": "01:02:03+24:00",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid time numoffset minute",
+ "data": "01:02:03+00:60",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid time with both Z and numoffset",
+ "data": "01:02:03Z+00:30",
+ "valid": false
+ },
+ {
"description": "an invalid time string",
"data": "08:30:06 PST",
"valid": false
diff --git a/json/tests/draft2020-12/ref.json b/json/tests/draft2020-12/ref.json
index d74e4a3..cd002a0 100644
--- a/json/tests/draft2020-12/ref.json
+++ b/json/tests/draft2020-12/ref.json
@@ -422,11 +422,16 @@
},
"tests": [
{
- "description": "do not evaluate the $ref inside the enum",
+ "description": "do not evaluate the $ref inside the enum, matching any string",
"data": "this is a string",
"valid": false
},
{
+ "description": "do not evaluate the $ref inside the enum, definition exact match",
+ "data": { "type": "string" },
+ "valid": false
+ },
+ {
"description": "match the enum exactly",
"data": { "$ref": "#/$defs/a_string" },
"valid": true
diff --git a/json/tests/draft2020-12/unevaluatedItems.json b/json/tests/draft2020-12/unevaluatedItems.json
index 13c80a2..0061769 100644
--- a/json/tests/draft2020-12/unevaluatedItems.json
+++ b/json/tests/draft2020-12/unevaluatedItems.json
@@ -485,5 +485,113 @@
"valid": false
}
]
+ },
+ {
+ "description": "unevaluatedItems depends on adjacent contains",
+ "schema": {
+ "prefixItems": [true],
+ "contains": {"type": "string"},
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "second item is evaluated by contains",
+ "data": [ 1, "foo" ],
+ "valid": true
+ },
+ {
+ "description": "contains fails, second item is not evaluated",
+ "data": [ 1, 2 ],
+ "valid": false
+ },
+ {
+ "description": "contains passes, second item is not evaluated",
+ "data": [ 1, 2, "foo" ],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems depends on multiple nested contains",
+ "schema": {
+ "allOf": [
+ { "contains": { "multipleOf": 2 } },
+ { "contains": { "multipleOf": 3 } }
+ ],
+ "unevaluatedItems": { "multipleOf": 5 }
+ },
+ "tests": [
+ {
+ "description": "5 not evaluated, passes unevaluatedItems",
+ "data": [ 2, 3, 4, 5, 6 ],
+ "valid": true
+ },
+ {
+ "description": "7 not evaluated, fails unevaluatedItems",
+ "data": [ 2, 3, 4, 7, 8 ],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems and contains interact to control item dependency relationship",
+ "schema": {
+ "if": {
+ "contains": {"const": "a"}
+ },
+ "then": {
+ "if": {
+ "contains": {"const": "b"}
+ },
+ "then": {
+ "if": {
+ "contains": {"const": "c"}
+ }
+ }
+ },
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "empty array is valid",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "only a's are valid",
+ "data": [ "a", "a" ],
+ "valid": true
+ },
+ {
+ "description": "a's and b's are valid",
+ "data": [ "a", "b", "a", "b", "a" ],
+ "valid": true
+ },
+ {
+ "description": "a's, b's and c's are valid",
+ "data": [ "c", "a", "c", "c", "b", "a" ],
+ "valid": true
+ },
+ {
+ "description": "only b's are invalid",
+ "data": [ "b", "b" ],
+ "valid": false
+ },
+ {
+ "description": "only c's are invalid",
+ "data": [ "c", "c" ],
+ "valid": false
+ },
+ {
+ "description": "only b's and c's are invalid",
+ "data": [ "c", "b", "c", "b", "c" ],
+ "valid": false
+ },
+ {
+ "description": "only a's and c's are invalid",
+ "data": [ "c", "a", "c", "a", "c" ],
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft3/additionalItems.json b/json/tests/draft3/additionalItems.json
index 1e8ebdc..910f1d6 100644
--- a/json/tests/draft3/additionalItems.json
+++ b/json/tests/draft3/additionalItems.json
@@ -19,7 +19,7 @@
]
},
{
- "description": "items is schema, no additionalItems",
+ "description": "when items is schema, additionalItems does nothing",
"schema": {
"items": {},
"additionalItems": false
@@ -33,7 +33,7 @@
]
},
{
- "description": "array of items with no additionalItems",
+ "description": "array of items with no additionalItems permitted",
"schema": {
"items": [{}, {}, {}],
"additionalItems": false
diff --git a/json/tests/draft3/default.json b/json/tests/draft3/default.json
index 1762977..289a9b6 100644
--- a/json/tests/draft3/default.json
+++ b/json/tests/draft3/default.json
@@ -45,5 +45,35 @@
"valid": true
}
]
+ },
+ {
+ "description": "the default keyword does not do anything if the property is missing",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "alpha": {
+ "type": "number",
+ "maximum": 3,
+ "default": 5
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "an explicit property value is checked against maximum (passing)",
+ "data": { "alpha": 1 },
+ "valid": true
+ },
+ {
+ "description": "an explicit property value is checked against maximum (failing)",
+ "data": { "alpha": 5 },
+ "valid": false
+ },
+ {
+ "description": "missing properties are not filled in with the default",
+ "data": {},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft3/ref.json b/json/tests/draft3/ref.json
index ebdb236..26dcb52 100644
--- a/json/tests/draft3/ref.json
+++ b/json/tests/draft3/ref.json
@@ -228,7 +228,7 @@
},
"tests": [
{
- "description": "do not evaluate the $ref inside the enum",
+ "description": "do not evaluate the $ref inside the enum, matching any string",
"data": "this is a string",
"valid": false
},
diff --git a/json/tests/draft4/additionalItems.json b/json/tests/draft4/additionalItems.json
index ee46b61..784bc84 100644
--- a/json/tests/draft4/additionalItems.json
+++ b/json/tests/draft4/additionalItems.json
@@ -19,7 +19,7 @@
]
},
{
- "description": "items is schema, no additionalItems",
+ "description": "when items is schema, additionalItems does nothing",
"schema": {
"items": {},
"additionalItems": false
@@ -33,7 +33,7 @@
]
},
{
- "description": "array of items with no additionalItems",
+ "description": "array of items with no additionalItems permitted",
"schema": {
"items": [{}, {}, {}],
"additionalItems": false
@@ -126,5 +126,24 @@
"valid": false
}
]
+ },
+ {
+ "description": "items validation adjusts the starting index for additionalItems",
+ "schema": {
+ "items": [ { "type": "string" } ],
+ "additionalItems": { "type": "integer" }
+ },
+ "tests": [
+ {
+ "description": "valid items",
+ "data": [ "x", 2, 3 ],
+ "valid": true
+ },
+ {
+ "description": "wrong type of second item",
+ "data": [ "x", "y" ],
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft4/default.json b/json/tests/draft4/default.json
index 1762977..289a9b6 100644
--- a/json/tests/draft4/default.json
+++ b/json/tests/draft4/default.json
@@ -45,5 +45,35 @@
"valid": true
}
]
+ },
+ {
+ "description": "the default keyword does not do anything if the property is missing",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "alpha": {
+ "type": "number",
+ "maximum": 3,
+ "default": 5
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "an explicit property value is checked against maximum (passing)",
+ "data": { "alpha": 1 },
+ "valid": true
+ },
+ {
+ "description": "an explicit property value is checked against maximum (failing)",
+ "data": { "alpha": 5 },
+ "valid": false
+ },
+ {
+ "description": "missing properties are not filled in with the default",
+ "data": {},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft4/ref.json b/json/tests/draft4/ref.json
index 33f7441..48544ba 100644
--- a/json/tests/draft4/ref.json
+++ b/json/tests/draft4/ref.json
@@ -447,7 +447,7 @@
},
"tests": [
{
- "description": "do not evaluate the $ref inside the enum",
+ "description": "do not evaluate the $ref inside the enum, matching any string",
"data": "this is a string",
"valid": false
},
diff --git a/json/tests/draft6/additionalItems.json b/json/tests/draft6/additionalItems.json
index ee46b61..784bc84 100644
--- a/json/tests/draft6/additionalItems.json
+++ b/json/tests/draft6/additionalItems.json
@@ -19,7 +19,7 @@
]
},
{
- "description": "items is schema, no additionalItems",
+ "description": "when items is schema, additionalItems does nothing",
"schema": {
"items": {},
"additionalItems": false
@@ -33,7 +33,7 @@
]
},
{
- "description": "array of items with no additionalItems",
+ "description": "array of items with no additionalItems permitted",
"schema": {
"items": [{}, {}, {}],
"additionalItems": false
@@ -126,5 +126,24 @@
"valid": false
}
]
+ },
+ {
+ "description": "items validation adjusts the starting index for additionalItems",
+ "schema": {
+ "items": [ { "type": "string" } ],
+ "additionalItems": { "type": "integer" }
+ },
+ "tests": [
+ {
+ "description": "valid items",
+ "data": [ "x", 2, 3 ],
+ "valid": true
+ },
+ {
+ "description": "wrong type of second item",
+ "data": [ "x", "y" ],
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft6/default.json b/json/tests/draft6/default.json
index 1762977..289a9b6 100644
--- a/json/tests/draft6/default.json
+++ b/json/tests/draft6/default.json
@@ -45,5 +45,35 @@
"valid": true
}
]
+ },
+ {
+ "description": "the default keyword does not do anything if the property is missing",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "alpha": {
+ "type": "number",
+ "maximum": 3,
+ "default": 5
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "an explicit property value is checked against maximum (passing)",
+ "data": { "alpha": 1 },
+ "valid": true
+ },
+ {
+ "description": "an explicit property value is checked against maximum (failing)",
+ "data": { "alpha": 5 },
+ "valid": false
+ },
+ {
+ "description": "missing properties are not filled in with the default",
+ "data": {},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft6/id.json b/json/tests/draft6/id.json
index 1c91d33..d276001 100644
--- a/json/tests/draft6/id.json
+++ b/json/tests/draft6/id.json
@@ -7,18 +7,18 @@
"id_in_enum": {
"enum": [
{
- "id": "https://localhost:1234/my_identifier.json",
+ "$id": "https://localhost:1234/my_identifier.json",
"type": "null"
}
]
},
"real_id_in_schema": {
- "id": "https://localhost:1234/my_identifier.json",
+ "$id": "https://localhost:1234/my_identifier.json",
"type": "string"
},
"zzz_id_in_const": {
"const": {
- "id": "https://localhost:1234/my_identifier.json",
+ "$id": "https://localhost:1234/my_identifier.json",
"type": "null"
}
}
@@ -32,7 +32,7 @@
{
"description": "exact match to enum, and type matches",
"data": {
- "id": "https://localhost:1234/my_identifier.json",
+ "$id": "https://localhost:1234/my_identifier.json",
"type": "null"
},
"valid": true
diff --git a/json/tests/draft6/ref.json b/json/tests/draft6/ref.json
index 676d6a0..0357f3e 100644
--- a/json/tests/draft6/ref.json
+++ b/json/tests/draft6/ref.json
@@ -479,11 +479,16 @@
},
"tests": [
{
- "description": "do not evaluate the $ref inside the enum",
+ "description": "do not evaluate the $ref inside the enum, matching any string",
"data": "this is a string",
"valid": false
},
{
+ "description": "do not evaluate the $ref inside the enum, definition exact match",
+ "data": { "type": "string" },
+ "valid": false
+ },
+ {
"description": "match the enum exactly",
"data": { "$ref": "#/definitions/a_string" },
"valid": true
diff --git a/json/tests/draft7/additionalItems.json b/json/tests/draft7/additionalItems.json
index ee46b61..784bc84 100644
--- a/json/tests/draft7/additionalItems.json
+++ b/json/tests/draft7/additionalItems.json
@@ -19,7 +19,7 @@
]
},
{
- "description": "items is schema, no additionalItems",
+ "description": "when items is schema, additionalItems does nothing",
"schema": {
"items": {},
"additionalItems": false
@@ -33,7 +33,7 @@
]
},
{
- "description": "array of items with no additionalItems",
+ "description": "array of items with no additionalItems permitted",
"schema": {
"items": [{}, {}, {}],
"additionalItems": false
@@ -126,5 +126,24 @@
"valid": false
}
]
+ },
+ {
+ "description": "items validation adjusts the starting index for additionalItems",
+ "schema": {
+ "items": [ { "type": "string" } ],
+ "additionalItems": { "type": "integer" }
+ },
+ "tests": [
+ {
+ "description": "valid items",
+ "data": [ "x", 2, 3 ],
+ "valid": true
+ },
+ {
+ "description": "wrong type of second item",
+ "data": [ "x", "y" ],
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft7/default.json b/json/tests/draft7/default.json
index 1762977..289a9b6 100644
--- a/json/tests/draft7/default.json
+++ b/json/tests/draft7/default.json
@@ -45,5 +45,35 @@
"valid": true
}
]
+ },
+ {
+ "description": "the default keyword does not do anything if the property is missing",
+ "schema": {
+ "type": "object",
+ "properties": {
+ "alpha": {
+ "type": "number",
+ "maximum": 3,
+ "default": 5
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "an explicit property value is checked against maximum (passing)",
+ "data": { "alpha": 1 },
+ "valid": true
+ },
+ {
+ "description": "an explicit property value is checked against maximum (failing)",
+ "data": { "alpha": 5 },
+ "valid": false
+ },
+ {
+ "description": "missing properties are not filled in with the default",
+ "data": {},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft7/id.json b/json/tests/draft7/id.json
index 1c91d33..d276001 100644
--- a/json/tests/draft7/id.json
+++ b/json/tests/draft7/id.json
@@ -7,18 +7,18 @@
"id_in_enum": {
"enum": [
{
- "id": "https://localhost:1234/my_identifier.json",
+ "$id": "https://localhost:1234/my_identifier.json",
"type": "null"
}
]
},
"real_id_in_schema": {
- "id": "https://localhost:1234/my_identifier.json",
+ "$id": "https://localhost:1234/my_identifier.json",
"type": "string"
},
"zzz_id_in_const": {
"const": {
- "id": "https://localhost:1234/my_identifier.json",
+ "$id": "https://localhost:1234/my_identifier.json",
"type": "null"
}
}
@@ -32,7 +32,7 @@
{
"description": "exact match to enum, and type matches",
"data": {
- "id": "https://localhost:1234/my_identifier.json",
+ "$id": "https://localhost:1234/my_identifier.json",
"type": "null"
},
"valid": true
diff --git a/json/tests/draft7/optional/format/time.json b/json/tests/draft7/optional/format/time.json
index 4ec8a01..74e8bf9 100644
--- a/json/tests/draft7/optional/format/time.json
+++ b/json/tests/draft7/optional/format/time.json
@@ -5,10 +5,85 @@
"tests": [
{
"description": "a valid time string",
+ "data": "08:30:06Z",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with leap second",
+ "data": "23:59:60Z",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with leap second with offset",
+ "data": "15:59:60-08:00",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with second fraction",
+ "data": "23:20:50.52Z",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with precise second fraction",
"data": "08:30:06.283185Z",
"valid": true
},
{
+ "description": "a valid time string with plus offset",
+ "data": "08:30:06+00:20",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with minus offset",
+ "data": "08:30:06-08:00",
+ "valid": true
+ },
+ {
+ "description": "a valid time string with case-insensitive Z",
+ "data": "08:30:06z",
+ "valid": true
+ },
+ {
+ "description": "an invalid time string with invalid hour",
+ "data": "24:00:00Z",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid minute",
+ "data": "00:60:00Z",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid second",
+ "data": "00:00:61Z",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid leap second (wrong hour)",
+ "data": "22:59:60Z",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid leap second (wrong minute)",
+ "data": "23:58:60Z",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid time numoffset hour",
+ "data": "01:02:03+24:00",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid time numoffset minute",
+ "data": "01:02:03+00:60",
+ "valid": false
+ },
+ {
+ "description": "an invalid time string with invalid time with both Z and numoffset",
+ "data": "01:02:03Z+00:30",
+ "valid": false
+ },
+ {
"description": "an invalid time string",
"data": "08:30:06 PST",
"valid": false
diff --git a/json/tests/draft7/ref.json b/json/tests/draft7/ref.json
index 80a4d1d..2ad0193 100644
--- a/json/tests/draft7/ref.json
+++ b/json/tests/draft7/ref.json
@@ -479,11 +479,16 @@
},
"tests": [
{
- "description": "do not evaluate the $ref inside the enum",
+ "description": "do not evaluate the $ref inside the enum, matching any string",
"data": "this is a string",
"valid": false
},
{
+ "description": "do not evaluate the $ref inside the enum, definition exact match",
+ "data": { "type": "string" },
+ "valid": false
+ },
+ {
"description": "match the enum exactly",
"data": { "$ref": "#/definitions/a_string" },
"valid": true