Skip to content

Commit 053b64b

Browse files
committed
HTTP -> HTTPS for specification URIs.
As per the note from https://json-schema.org/specification-links.html#published-drafts Backwards compatibility is preserved for existing validators. Going forward likely only the HTTPS URI will be supported for draft2019-09 and forward.
1 parent 7631988 commit 053b64b

File tree

7 files changed

+152
-50
lines changed

7 files changed

+152
-50
lines changed

jsonschema/benchmarks/issue232/issue.json

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"schema": {
55
"title": "A JSON Schema for Swagger 2.0 API.",
66
"id": "http://swagger.io/v2/schema.json#",
7-
"$schema": "http://json-schema.org/draft-04/schema#",
7+
"$schema": "https://json-schema.org/draft-04/schema#",
88
"type": "object",
99
"required": [
1010
"swagger",
@@ -951,58 +951,58 @@
951951
"type": "string"
952952
},
953953
"title": {
954-
"$ref": "http://json-schema.org/draft-04/schema#/properties/title"
954+
"$ref": "https://json-schema.org/draft-04/schema#/properties/title"
955955
},
956956
"description": {
957-
"$ref": "http://json-schema.org/draft-04/schema#/properties/description"
957+
"$ref": "https://json-schema.org/draft-04/schema#/properties/description"
958958
},
959959
"default": {
960-
"$ref": "http://json-schema.org/draft-04/schema#/properties/default"
960+
"$ref": "https://json-schema.org/draft-04/schema#/properties/default"
961961
},
962962
"multipleOf": {
963-
"$ref": "http://json-schema.org/draft-04/schema#/properties/multipleOf"
963+
"$ref": "https://json-schema.org/draft-04/schema#/properties/multipleOf"
964964
},
965965
"maximum": {
966-
"$ref": "http://json-schema.org/draft-04/schema#/properties/maximum"
966+
"$ref": "https://json-schema.org/draft-04/schema#/properties/maximum"
967967
},
968968
"exclusiveMaximum": {
969-
"$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum"
969+
"$ref": "https://json-schema.org/draft-04/schema#/properties/exclusiveMaximum"
970970
},
971971
"minimum": {
972-
"$ref": "http://json-schema.org/draft-04/schema#/properties/minimum"
972+
"$ref": "https://json-schema.org/draft-04/schema#/properties/minimum"
973973
},
974974
"exclusiveMinimum": {
975-
"$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum"
975+
"$ref": "https://json-schema.org/draft-04/schema#/properties/exclusiveMinimum"
976976
},
977977
"maxLength": {
978-
"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
978+
"$ref": "https://json-schema.org/draft-04/schema#/definitions/positiveInteger"
979979
},
980980
"minLength": {
981-
"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
981+
"$ref": "https://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
982982
},
983983
"pattern": {
984-
"$ref": "http://json-schema.org/draft-04/schema#/properties/pattern"
984+
"$ref": "https://json-schema.org/draft-04/schema#/properties/pattern"
985985
},
986986
"maxItems": {
987-
"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
987+
"$ref": "https://json-schema.org/draft-04/schema#/definitions/positiveInteger"
988988
},
989989
"minItems": {
990-
"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
990+
"$ref": "https://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
991991
},
992992
"uniqueItems": {
993-
"$ref": "http://json-schema.org/draft-04/schema#/properties/uniqueItems"
993+
"$ref": "https://json-schema.org/draft-04/schema#/properties/uniqueItems"
994994
},
995995
"maxProperties": {
996-
"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
996+
"$ref": "https://json-schema.org/draft-04/schema#/definitions/positiveInteger"
997997
},
998998
"minProperties": {
999-
"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
999+
"$ref": "https://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
10001000
},
10011001
"required": {
1002-
"$ref": "http://json-schema.org/draft-04/schema#/definitions/stringArray"
1002+
"$ref": "https://json-schema.org/draft-04/schema#/definitions/stringArray"
10031003
},
10041004
"enum": {
1005-
"$ref": "http://json-schema.org/draft-04/schema#/properties/enum"
1005+
"$ref": "https://json-schema.org/draft-04/schema#/properties/enum"
10061006
},
10071007
"additionalProperties": {
10081008
"anyOf": [
@@ -1016,7 +1016,7 @@
10161016
"default": {}
10171017
},
10181018
"type": {
1019-
"$ref": "http://json-schema.org/draft-04/schema#/properties/type"
1019+
"$ref": "https://json-schema.org/draft-04/schema#/properties/type"
10201020
},
10211021
"items": {
10221022
"anyOf": [
@@ -1080,16 +1080,16 @@
10801080
"type": "string"
10811081
},
10821082
"title": {
1083-
"$ref": "http://json-schema.org/draft-04/schema#/properties/title"
1083+
"$ref": "https://json-schema.org/draft-04/schema#/properties/title"
10841084
},
10851085
"description": {
1086-
"$ref": "http://json-schema.org/draft-04/schema#/properties/description"
1086+
"$ref": "https://json-schema.org/draft-04/schema#/properties/description"
10871087
},
10881088
"default": {
1089-
"$ref": "http://json-schema.org/draft-04/schema#/properties/default"
1089+
"$ref": "https://json-schema.org/draft-04/schema#/properties/default"
10901090
},
10911091
"required": {
1092-
"$ref": "http://json-schema.org/draft-04/schema#/definitions/stringArray"
1092+
"$ref": "https://json-schema.org/draft-04/schema#/definitions/stringArray"
10931093
},
10941094
"type": {
10951095
"type": "string",
@@ -1550,49 +1550,49 @@
15501550
"default": "csv"
15511551
},
15521552
"title": {
1553-
"$ref": "http://json-schema.org/draft-04/schema#/properties/title"
1553+
"$ref": "https://json-schema.org/draft-04/schema#/properties/title"
15541554
},
15551555
"description": {
1556-
"$ref": "http://json-schema.org/draft-04/schema#/properties/description"
1556+
"$ref": "https://json-schema.org/draft-04/schema#/properties/description"
15571557
},
15581558
"default": {
1559-
"$ref": "http://json-schema.org/draft-04/schema#/properties/default"
1559+
"$ref": "https://json-schema.org/draft-04/schema#/properties/default"
15601560
},
15611561
"multipleOf": {
1562-
"$ref": "http://json-schema.org/draft-04/schema#/properties/multipleOf"
1562+
"$ref": "https://json-schema.org/draft-04/schema#/properties/multipleOf"
15631563
},
15641564
"maximum": {
1565-
"$ref": "http://json-schema.org/draft-04/schema#/properties/maximum"
1565+
"$ref": "https://json-schema.org/draft-04/schema#/properties/maximum"
15661566
},
15671567
"exclusiveMaximum": {
1568-
"$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum"
1568+
"$ref": "https://json-schema.org/draft-04/schema#/properties/exclusiveMaximum"
15691569
},
15701570
"minimum": {
1571-
"$ref": "http://json-schema.org/draft-04/schema#/properties/minimum"
1571+
"$ref": "https://json-schema.org/draft-04/schema#/properties/minimum"
15721572
},
15731573
"exclusiveMinimum": {
1574-
"$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum"
1574+
"$ref": "https://json-schema.org/draft-04/schema#/properties/exclusiveMinimum"
15751575
},
15761576
"maxLength": {
1577-
"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
1577+
"$ref": "https://json-schema.org/draft-04/schema#/definitions/positiveInteger"
15781578
},
15791579
"minLength": {
1580-
"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
1580+
"$ref": "https://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
15811581
},
15821582
"pattern": {
1583-
"$ref": "http://json-schema.org/draft-04/schema#/properties/pattern"
1583+
"$ref": "https://json-schema.org/draft-04/schema#/properties/pattern"
15841584
},
15851585
"maxItems": {
1586-
"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
1586+
"$ref": "https://json-schema.org/draft-04/schema#/definitions/positiveInteger"
15871587
},
15881588
"minItems": {
1589-
"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
1589+
"$ref": "https://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"
15901590
},
15911591
"uniqueItems": {
1592-
"$ref": "http://json-schema.org/draft-04/schema#/properties/uniqueItems"
1592+
"$ref": "https://json-schema.org/draft-04/schema#/properties/uniqueItems"
15931593
},
15941594
"enum": {
1595-
"$ref": "http://json-schema.org/draft-04/schema#/properties/enum"
1595+
"$ref": "https://json-schema.org/draft-04/schema#/properties/enum"
15961596
},
15971597
"jsonReference": {
15981598
"type": "object",

jsonschema/schemas/draft3.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"$schema": "http://json-schema.org/draft-03/schema#",
2+
"$schema": "https://json-schema.org/draft-03/schema#",
33
"dependencies": {
44
"exclusiveMaximum": "maximum",
55
"exclusiveMinimum": "minimum"
66
},
7-
"id": "http://json-schema.org/draft-03/schema#",
7+
"id": "https://json-schema.org/draft-03/schema#",
88
"properties": {
99
"$ref": {
1010
"format": "uri",

jsonschema/schemas/draft4.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "http://json-schema.org/draft-04/schema#",
2+
"$schema": "https://json-schema.org/draft-04/schema#",
33
"default": {},
44
"definitions": {
55
"positiveInteger": {
@@ -52,7 +52,7 @@
5252
]
5353
},
5454
"description": "Core schema meta-schema",
55-
"id": "http://json-schema.org/draft-04/schema#",
55+
"id": "https://json-schema.org/draft-04/schema#",
5656
"properties": {
5757
"$schema": {
5858
"format": "uri",

jsonschema/schemas/draft6.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"$schema": "http://json-schema.org/draft-06/schema#",
3-
"$id": "http://json-schema.org/draft-06/schema#",
2+
"$schema": "https://json-schema.org/draft-06/schema#",
3+
"$id": "https://json-schema.org/draft-06/schema#",
44
"title": "Core schema meta-schema",
55
"definitions": {
66
"schemaArray": {

jsonschema/schemas/draft7.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"$id": "http://json-schema.org/draft-07/schema#",
2+
"$schema": "https://json-schema.org/draft-07/schema#",
3+
"$id": "https://json-schema.org/draft-07/schema#",
44
"title": "Core schema meta-schema",
55
"definitions": {
66
"schemaArray": {

jsonschema/tests/test_validators.py

Lines changed: 99 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,19 @@ class TestDraft7Validator(ValidatorTestMixin, TestCase):
13551355

13561356
class TestValidatorFor(SynchronousTestCase):
13571357
def test_draft_3(self):
1358+
schema = {"$schema": "https://json-schema.org/draft-03/schema"}
1359+
self.assertIs(
1360+
validators.validator_for(schema),
1361+
validators.Draft3Validator,
1362+
)
1363+
1364+
schema = {"$schema": "https://json-schema.org/draft-03/schema#"}
1365+
self.assertIs(
1366+
validators.validator_for(schema),
1367+
validators.Draft3Validator,
1368+
)
1369+
1370+
def test_draft_3_http(self):
13581371
schema = {"$schema": "http://json-schema.org/draft-03/schema"}
13591372
self.assertIs(
13601373
validators.validator_for(schema),
@@ -1368,6 +1381,19 @@ def test_draft_3(self):
13681381
)
13691382

13701383
def test_draft_4(self):
1384+
schema = {"$schema": "https://json-schema.org/draft-04/schema"}
1385+
self.assertIs(
1386+
validators.validator_for(schema),
1387+
validators.Draft4Validator,
1388+
)
1389+
1390+
schema = {"$schema": "https://json-schema.org/draft-04/schema#"}
1391+
self.assertIs(
1392+
validators.validator_for(schema),
1393+
validators.Draft4Validator,
1394+
)
1395+
1396+
def test_draft_4_http(self):
13711397
schema = {"$schema": "http://json-schema.org/draft-04/schema"}
13721398
self.assertIs(
13731399
validators.validator_for(schema),
@@ -1381,6 +1407,19 @@ def test_draft_4(self):
13811407
)
13821408

13831409
def test_draft_6(self):
1410+
schema = {"$schema": "https://json-schema.org/draft-06/schema"}
1411+
self.assertIs(
1412+
validators.validator_for(schema),
1413+
validators.Draft6Validator,
1414+
)
1415+
1416+
schema = {"$schema": "https://json-schema.org/draft-06/schema#"}
1417+
self.assertIs(
1418+
validators.validator_for(schema),
1419+
validators.Draft6Validator,
1420+
)
1421+
1422+
def test_draft_6_http(self):
13841423
schema = {"$schema": "http://json-schema.org/draft-06/schema"}
13851424
self.assertIs(
13861425
validators.validator_for(schema),
@@ -1394,6 +1433,19 @@ def test_draft_6(self):
13941433
)
13951434

13961435
def test_draft_7(self):
1436+
schema = {"$schema": "https://json-schema.org/draft-07/schema"}
1437+
self.assertIs(
1438+
validators.validator_for(schema),
1439+
validators.Draft7Validator,
1440+
)
1441+
1442+
schema = {"$schema": "https://json-schema.org/draft-07/schema#"}
1443+
self.assertIs(
1444+
validators.validator_for(schema),
1445+
validators.Draft7Validator,
1446+
)
1447+
1448+
def test_draft_7_http(self):
13971449
schema = {"$schema": "http://json-schema.org/draft-07/schema"}
13981450
self.assertIs(
13991451
validators.validator_for(schema),
@@ -1476,6 +1528,50 @@ def assertUses(self, schema, Validator):
14761528
self.assertEqual(result, [schema])
14771529

14781530
def test_draft3_validator_is_chosen(self):
1531+
self.assertUses(
1532+
schema={"$schema": "https://json-schema.org/draft-03/schema#"},
1533+
Validator=validators.Draft3Validator,
1534+
)
1535+
# Make sure it works without the empty fragment
1536+
self.assertUses(
1537+
schema={"$schema": "https://json-schema.org/draft-03/schema"},
1538+
Validator=validators.Draft3Validator,
1539+
)
1540+
1541+
def test_draft4_validator_is_chosen(self):
1542+
self.assertUses(
1543+
schema={"$schema": "https://json-schema.org/draft-04/schema#"},
1544+
Validator=validators.Draft4Validator,
1545+
)
1546+
# Make sure it works without the empty fragment
1547+
self.assertUses(
1548+
schema={"$schema": "https://json-schema.org/draft-04/schema"},
1549+
Validator=validators.Draft4Validator,
1550+
)
1551+
1552+
def test_draft6_validator_is_chosen(self):
1553+
self.assertUses(
1554+
schema={"$schema": "https://json-schema.org/draft-06/schema#"},
1555+
Validator=validators.Draft6Validator,
1556+
)
1557+
# Make sure it works without the empty fragment
1558+
self.assertUses(
1559+
schema={"$schema": "https://json-schema.org/draft-06/schema"},
1560+
Validator=validators.Draft6Validator,
1561+
)
1562+
1563+
def test_draft7_validator_is_chosen(self):
1564+
self.assertUses(
1565+
schema={"$schema": "https://json-schema.org/draft-07/schema#"},
1566+
Validator=validators.Draft7Validator,
1567+
)
1568+
# Make sure it works without the empty fragment
1569+
self.assertUses(
1570+
schema={"$schema": "https://json-schema.org/draft-07/schema"},
1571+
Validator=validators.Draft7Validator,
1572+
)
1573+
1574+
def test_draft3_validator_is_chosen_http(self):
14791575
self.assertUses(
14801576
schema={"$schema": "http://json-schema.org/draft-03/schema#"},
14811577
Validator=validators.Draft3Validator,
@@ -1486,7 +1582,7 @@ def test_draft3_validator_is_chosen(self):
14861582
Validator=validators.Draft3Validator,
14871583
)
14881584

1489-
def test_draft4_validator_is_chosen(self):
1585+
def test_draft4_validator_is_chosen_http(self):
14901586
self.assertUses(
14911587
schema={"$schema": "http://json-schema.org/draft-04/schema#"},
14921588
Validator=validators.Draft4Validator,
@@ -1497,7 +1593,7 @@ def test_draft4_validator_is_chosen(self):
14971593
Validator=validators.Draft4Validator,
14981594
)
14991595

1500-
def test_draft6_validator_is_chosen(self):
1596+
def test_draft6_validator_is_chosen_http(self):
15011597
self.assertUses(
15021598
schema={"$schema": "http://json-schema.org/draft-06/schema#"},
15031599
Validator=validators.Draft6Validator,
@@ -1508,7 +1604,7 @@ def test_draft6_validator_is_chosen(self):
15081604
Validator=validators.Draft6Validator,
15091605
)
15101606

1511-
def test_draft7_validator_is_chosen(self):
1607+
def test_draft7_validator_is_chosen_http(self):
15121608
self.assertUses(
15131609
schema={"$schema": "http://json-schema.org/draft-07/schema#"},
15141610
Validator=validators.Draft7Validator,

jsonschema/validators.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,12 @@ def extend(validator, validators=(), version=None, type_checker=None):
589589
_LATEST_VERSION = Draft7Validator
590590

591591

592+
# Preserve backwards compatibility of using HTTP $ids for pre2019-09 validators
593+
for cls in Draft3Validator, Draft4Validator, Draft6Validator, Draft7Validator:
594+
_http_id = cls.ID_OF(cls.META_SCHEMA).replace("https://", "http://")
595+
meta_schemas[_http_id] = cls
596+
597+
592598
class RefResolver(object):
593599
"""
594600
Resolve JSON References.

0 commit comments

Comments
 (0)