Skip to content

Commit

Permalink
Squashed 'JSON-Schema-Test-Suite/' changes from 5cc9214e..d38ddd54
Browse files Browse the repository at this point in the history
d38ddd54 Merge pull request #696 from jdesrosiers/unevaluated-dynamicref
5d0c05fa Fix copy/paste error
95fe6ca2 Merge pull request #694 from json-schema-org/heterogeneous-additionalItems
9c88a0be Merge pull request #697 from json-schema-org/gregsdennis/add-ref-into-known-nonapplicator
49222046 Add unevaluted with dynamic ref tests to draft-next
8ba1c90d Update unevaluted with dynamic ref to be more likely to catch errors
fea2cf19 add tests for 2019 and 2020
6695ca38 add optional tests for `$ref`ing into known non-applicator keywords
2834c630 Add tests for unevaluated with dynamic reference
cda4281c Merge pull request #695 from json-schema-org/ether/clean-up-subSchemas
7b9f45c2 move subSchemas-defs.json to subSchemas.json
e41ec0ec remove unused definition files
349c5a82 Merge pull request #692 from json-schema-org/ether/fix-subSchemas-refs
451baca4 Merge pull request #670 from marksparkza/invalid-output-test
b8da838a Add tests for heterogeneous arrays with additionalItems
6d7a44b7 fix subschema locations and their $refs
a9a1e2e3 Merge pull request #690 from skryukov/add-ipv4-mask-test
ba52c48a Merge pull request #689 from skryukov/add-schema-keyword-to-required-tests
69b53add Add a test case for ipv4 with netmask
d0c602a7 Add $schema keyword to required tests
20f1f52c Merge pull request #688 from spacether/feat_updates_python_exp_impl
b087b3ca Updates implmentation
4ecd01f3 Merge pull request #687 from swaeberle/check-single-label-idn-hostnames
732e7275 test single label IDN hostnames
ab3924a6 Merge pull request #685 from swaeberle/check-single-label-hostnames
9265a4fa do not test hostname with leading digit for older drafts
261b52db do not allow starting digits in hostnames for older drafts
9fc231ea test digits in hostnames
e9b20158 test plain single label hostnames
c8b57093 test valid single label hostnames
299aa7fe Merge pull request #682 from json-schema-org/useless-branch
fbb3cac6 Bump the sanity check to use a released version of jsonschema
ea0b63c9 Remove invalid output tests

git-subtree-dir: JSON-Schema-Test-Suite
git-subtree-split: d38ddd543ebc81e5c23ab03d6598c06563c38a17
  • Loading branch information
davishmcclurg committed Nov 16, 2023
1 parent 9b3b9e9 commit 8c77a42
Show file tree
Hide file tree
Showing 58 changed files with 876 additions and 145 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ Node-specific support is maintained in a [separate repository](https://github.co
* [fastjsonschema](https://github.com/seznam/python-fastjsonschema)
* [hypothesis-jsonschema](https://github.com/Zac-HD/hypothesis-jsonschema)
* [jschon](https://github.com/marksparkza/jschon)
* [python-experimental, OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/python-experimental.md)
* [OpenAPI JSON Schema Generator](https://github.com/openapi-json-schema-tools/openapi-json-schema-generator)

### Ruby

Expand Down
9 changes: 4 additions & 5 deletions bin/jsonschema_suite
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import warnings
try:
import jsonschema.validators
except ImportError:
jsonschema = None
jsonschema = Unresolvable = None
VALIDATORS = {}
else:
from referencing.exceptions import Unresolvable

VALIDATORS = {
"draft3": jsonschema.validators.Draft3Validator,
"draft4": jsonschema.validators.Draft4Validator,
Expand Down Expand Up @@ -587,7 +589,7 @@ class SanityTests(unittest.TestCase):
with self.subTest(case=case, version=version.name):
try:
Validator(case["schema"]).is_valid(12)
except jsonschema.exceptions.RefResolutionError:
except Unresolvable:
pass

@unittest.skipIf(jsonschema is None, "Validation library not present!")
Expand Down Expand Up @@ -615,9 +617,6 @@ class SanityTests(unittest.TestCase):
with self.subTest(path=path):
try:
validator.validate(cases)
except jsonschema.exceptions.RefResolutionError:
# python-jsonschema/jsonschema#884
pass
except jsonschema.ValidationError as error:
self.fail(str(error))

Expand Down
26 changes: 0 additions & 26 deletions output-tests/draft2019-09/content/type.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,6 @@
"required": ["errors"]
}
}
},
{
"description": "correct type yields an output unit",
"data": "a string",
"output": {
"basic": {
"$id": "https://json-schema.org/tests/content/draft2019-09/type/0/tests/1/basic",
"$ref": "/draft/2019-09/output/schema",
"properties": {
"annotations": {
"contains": {
"properties": {
"valid": {"const": true},
"keywordLocation": {"const": "/type"},
"absoluteKeywordLocation": {"const": "https://json-schema.org/tests/content/draft2019-09/type/0#/type"},
"instanceLocation": {"const": ""},
"annotation": false,
"error": false
},
"required": ["keywordLocation", "instanceLocation"]
}
}
},
"required": ["annotations"]
}
}
}
]
}
Expand Down
26 changes: 0 additions & 26 deletions output-tests/draft2020-12/content/type.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,6 @@
"required": ["errors"]
}
}
},
{
"description": "correct type yields an output unit",
"data": "a string",
"output": {
"basic": {
"$id": "https://json-schema.org/tests/content/draft2020-12/type/0/tests/1/basic",
"$ref": "/draft/2020-12/output/schema",
"properties": {
"annotations": {
"contains": {
"properties": {
"valid": {"const": true},
"keywordLocation": {"const": "/type"},
"absoluteKeywordLocation": {"const": "https://json-schema.org/tests/content/draft2020-12/type/0#/type"},
"instanceLocation": {"const": ""},
"annotation": false,
"error": false
},
"required": ["keywordLocation", "instanceLocation"]
}
}
},
"required": ["annotations"]
}
}
}
]
}
Expand Down
11 changes: 0 additions & 11 deletions remotes/draft-next/subSchemas-defs.json

This file was deleted.

12 changes: 7 additions & 5 deletions remotes/draft-next/subSchemas.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"$schema": "https://json-schema.org/draft/next/schema",
"integer": {
"type": "integer"
},
"refToInteger": {
"$ref": "#/integer"
"$defs": {
"integer": {
"type": "integer"
},
"refToInteger": {
"$ref": "#/$defs/integer"
}
}
}
11 changes: 0 additions & 11 deletions remotes/draft2019-09/subSchemas-defs.json

This file was deleted.

12 changes: 7 additions & 5 deletions remotes/draft2019-09/subSchemas.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"integer": {
"type": "integer"
},
"refToInteger": {
"$ref": "#/integer"
"$defs": {
"integer": {
"type": "integer"
},
"refToInteger": {
"$ref": "#/$defs/integer"
}
}
}
11 changes: 0 additions & 11 deletions remotes/draft2020-12/subSchemas-defs.json

This file was deleted.

12 changes: 7 additions & 5 deletions remotes/draft2020-12/subSchemas.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"integer": {
"type": "integer"
},
"refToInteger": {
"$ref": "#/integer"
"$defs": {
"integer": {
"type": "integer"
},
"refToInteger": {
"$ref": "#/$defs/integer"
}
}
}
10 changes: 0 additions & 10 deletions remotes/subSchemas-defs.json

This file was deleted.

12 changes: 7 additions & 5 deletions remotes/subSchemas.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"integer": {
"type": "integer"
},
"refToInteger": {
"$ref": "#/integer"
"definitions": {
"integer": {
"type": "integer"
},
"refToInteger": {
"$ref": "#/definitions/integer"
}
}
}
1 change: 1 addition & 0 deletions tests/draft-next/dependentSchemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
{
"description": "dependent subschema incompatible with root",
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"properties": {
"foo": {}
},
Expand Down
20 changes: 20 additions & 0 deletions tests/draft-next/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,26 @@
}
]
},
{
"description": "items with heterogeneous array",
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"prefixItems": [{}],
"items": false
},
"tests": [
{
"description": "heterogeneous invalid instance",
"data": [ "foo", "bar", 37 ],
"valid": false
},
{
"description": "valid instance",
"data": [ null ],
"valid": true
}
]
},
{
"description": "items with null instance elements",
"schema": {
Expand Down
25 changes: 25 additions & 0 deletions tests/draft-next/optional/format/hostname.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,31 @@
"description": "exceeds maximum label length",
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
"valid": false
},
{
"description": "single label",
"data": "hostname",
"valid": true
},
{
"description": "single label with hyphen",
"data": "host-name",
"valid": true
},
{
"description": "single label with digits",
"data": "h0stn4me",
"valid": true
},
{
"description": "single label starting with digit",
"data": "1host",
"valid": true
},
{
"description": "single label ending with digit",
"data": "hostnam3",
"valid": true
}
]
}
Expand Down
25 changes: 25 additions & 0 deletions tests/draft-next/optional/format/idn-hostname.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,31 @@
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.1 https://www.w3.org/TR/alreq/#h_disjoining_enforcement",
"data": "\u0628\u064a\u200c\u0628\u064a",
"valid": true
},
{
"description": "single label",
"data": "hostname",
"valid": true
},
{
"description": "single label with hyphen",
"data": "host-name",
"valid": true
},
{
"description": "single label with digits",
"data": "h0stn4me",
"valid": true
},
{
"description": "single label starting with digit",
"data": "1host",
"valid": true
},
{
"description": "single label ending with digit",
"data": "hostnam3",
"valid": true
}
]
}
Expand Down
5 changes: 5 additions & 0 deletions tests/draft-next/optional/format/ipv4.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
"description": "invalid non-ASCII '২' (a Bengali 2)",
"data": "1২7.0.0.1",
"valid": false
},
{
"description": "netmask is not a part of ipv4 address",
"data": "192.168.1.0/24",
"valid": false
}
]
}
Expand Down
23 changes: 23 additions & 0 deletions tests/draft-next/optional/refOfUnknownKeyword.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,28 @@
"valid": false
}
]
},
{
"description": "reference internals of known non-applicator",
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"$id": "/base",
"examples": [
{ "type": "string" }
],
"$ref": "#/examples/0"
},
"tests": [
{
"description": "match",
"data": "a string",
"valid": true
},
{
"description": "mismatch",
"data": 42,
"valid": false
}
]
}
]

0 comments on commit 8c77a42

Please sign in to comment.