Skip to content

Commit

Permalink
Squashed 'json/' changes from 15ec577f..09fd353f
Browse files Browse the repository at this point in the history
09fd353f Merge pull request #481 from kylef/kylef/time
0ed2e79b Fix negative time test to only fail on a single rule
2edc74b1 Add valid time with different second fractions
7bde0bf7 Add valid time with leap second including offset
ee83f464 Stricter time format constraints
5732904a Merge pull request #480 from json-schema-org/ether/better-test-names
c2994271 better test names for schema-items + additionalItems
6bc53e60 Merge pull request #479 from json-schema-org/fix-non-id-in-enum-for-drafts-6-and-7
3f783d9c fixing draft 6 & 7 non-id tests
5768c68d Merge pull request #476 from json-schema-org/ether/readme-updates
0c8bfc06 add mention of JSON::Schema::Tiny
e4c10c6b fix markdown for underscores in package names
eeb4db18 mention draft2020-12 in readme
dff69dcb Merge pull request #474 from marksparkza/unevaluatedItems-depends-on-contains
51b4977c Merge pull request #478 from sorinsarca/patch-1
dfcd4a19 fix bad comma
4cb100a5 Merge pull request #465 from json-schema-org/ether/more-naive-ref
31dc86bc add another test of naive $ref replacement
f858c613 Merge pull request #477 from json-schema-org/ether/more-items-tests
4e266c34 test that array-items/prefixItems adjusts the starting position for schema-items/additionalItems
b7fced33 Merge pull request #473 from json-schema-org/ether/more-default-tests
eadb9be7 test that a missing property is not populated by the default in the actual instance data
839b95d8 Added opis/json-schema
7cf78800 Add missing comma
3390c871 Update tests/draft2020-12/unevaluatedItems.json
d3b88001 Update tests/draft2020-12/unevaluatedItems.json
84e1d5a9 Add another test case for unevaluatedItems-contains interaction
f400802c Add tests for unevaluatedItems interaction with contains

git-subtree-dir: json
git-subtree-split: 09fd353fc44ab22e7e8998d096b3d6d83287e5e6
  • Loading branch information
Julian committed Apr 28, 2021
1 parent 61d6022 commit c19f0b4
Show file tree
Hide file tree
Showing 25 changed files with 660 additions and 30 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
23 changes: 21 additions & 2 deletions tests/draft2019-09/additionalItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
]
},
{
"description": "items is schema, no additionalItems",
"description": "when items is schema, additionalItems does nothing",
"schema": {
"items": {},
"additionalItems": false
Expand All @@ -33,7 +33,7 @@
]
},
{
"description": "array of items with no additionalItems",
"description": "array of items with no additionalItems permitted",
"schema": {
"items": [{}, {}, {}],
"additionalItems": false
Expand Down Expand Up @@ -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
}
]
}
]
30 changes: 30 additions & 0 deletions tests/draft2019-09/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
]
75 changes: 75 additions & 0 deletions tests/draft2019-09/optional/format/time.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,84 @@
"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",
Expand Down
7 changes: 6 additions & 1 deletion tests/draft2019-09/ref.json
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,15 @@
},
"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" },
Expand Down
30 changes: 30 additions & 0 deletions tests/draft2020-12/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
]
19 changes: 19 additions & 0 deletions tests/draft2020-12/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
]
75 changes: 75 additions & 0 deletions tests/draft2020-12/optional/format/time.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,84 @@
"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",
Expand Down
7 changes: 6 additions & 1 deletion tests/draft2020-12/ref.json
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,15 @@
},
"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" },
Expand Down
Loading

0 comments on commit c19f0b4

Please sign in to comment.