diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 63e83306..8d77ddb5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,9 @@ v4.19.0 * Importing the ``Validator`` protocol directly from the package root is deprecated. Import it from ``jsonschema.protocols.Validator`` instead. +* Automatic retrieval of remote references (which is still deprecated) now properly succeeds even if the retrieved resource does not declare which version of JSON Schema it uses. + Such resources are assumed to be 2020-12 schemas. + This more closely matches the pre-referencing library behavior. v4.18.6 ======= diff --git a/jsonschema/tests/test_deprecations.py b/jsonschema/tests/test_deprecations.py index 237d80dc..fdb3b7b0 100644 --- a/jsonschema/tests/test_deprecations.py +++ b/jsonschema/tests/test_deprecations.py @@ -381,10 +381,7 @@ def test_automatic_remote_retrieval(self): Automatic retrieval of remote references is deprecated as of v4.18.0. """ ref = "http://bar#/$defs/baz" - schema = { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$defs": {"baz": {"type": "integer"}}, - } + schema = {"$defs": {"baz": {"type": "integer"}}} if "requests" in sys.modules: # pragma: no cover self.addCleanup( diff --git a/jsonschema/validators.py b/jsonschema/validators.py index 0ba8adb0..8049e8b2 100644 --- a/jsonschema/validators.py +++ b/jsonschema/validators.py @@ -119,7 +119,10 @@ def _warn_for_remote_retrieve(uri: str): DeprecationWarning, stacklevel=9, # Ha ha ha ha magic numbers :/ ) - return referencing.Resource.from_contents(json.load(response)) + return referencing.Resource.from_contents( + json.load(response), + default_specification=referencing.jsonschema.DRAFT202012, + ) _REMOTE_WARNING_REGISTRY = SPECIFICATIONS.combine(