Skip to content

Commit 21144f9

Browse files
committed
jsonschema 4.18 compatibility
1 parent a2a36ec commit 21144f9

File tree

7 files changed

+115
-97
lines changed

7 files changed

+115
-97
lines changed

openapi_core/spec/paths.py

+8-14
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import Type
88
from typing import TypeVar
99

10-
from jsonschema_spec import Spec as JsonschemaSpec
10+
from jsonschema_spec import SchemaPath
1111
from jsonschema_spec import default_handlers
1212
from openapi_spec_validator.validation import openapi_spec_validator_proxy
1313
from openapi_spec_validator.validation.protocols import SupportsValidation
@@ -17,7 +17,7 @@
1717
SPEC_SEPARATOR = "#"
1818

1919

20-
class Spec(JsonschemaSpec):
20+
class Spec(SchemaPath):
2121
@classmethod
2222
def create(
2323
cls: Type[TSpec],
@@ -47,21 +47,15 @@ def from_dict(
4747
cls: Type[TSpec],
4848
data: Mapping[Hashable, Any],
4949
*args: Any,
50-
spec_url: str = "",
51-
ref_resolver_handlers: Mapping[str, Any] = default_handlers,
52-
separator: str = SPEC_SEPARATOR,
53-
validator: Optional[SupportsValidation] = openapi_spec_validator_proxy,
50+
**kwargs: Any,
5451
) -> TSpec:
52+
validator = kwargs.pop("validator", None)
5553
if validator is not None:
56-
validator.validate(data, spec_url=spec_url)
54+
base_uri = kwargs.get("base_uri")
55+
spec_url = kwargs.get("spec_url")
56+
validator.validate(data, base_uri=base_uri, spec_url=spec_url)
5757

58-
return super().from_dict(
59-
data,
60-
*args,
61-
spec_url=spec_url,
62-
ref_resolver_handlers=ref_resolver_handlers,
63-
separator=separator,
64-
)
58+
return super().from_dict(data, *args, **kwargs)
6559

6660
def exists(self) -> bool:
6761
try:

openapi_core/validation/schemas/factories.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def create(
6363
with schema.open() as schema_dict:
6464
jsonschema_validator = self.schema_validator_class(
6565
schema_dict,
66-
resolver=resolver,
66+
_resolver=resolver,
6767
format_checker=format_checker,
6868
)
6969

poetry.lock

+89-63
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ starlette = {version = ">=0.26.1,<0.29.0", optional = true}
6767
isodate = "*"
6868
more-itertools = "*"
6969
parse = "*"
70-
openapi-schema-validator = "^0.4.2"
71-
openapi-spec-validator = "^0.5.0"
70+
openapi-schema-validator = {version = "^0.6.0a1", allow-prereleases = true}
71+
openapi-spec-validator = {version = "^0.6.0a2", allow-prereleases = true}
7272
requests = {version = "*", optional = true}
7373
werkzeug = "*"
74-
jsonschema-spec = "^0.1.6"
74+
jsonschema-spec = "^0.2.2"
7575
asgiref = "^3.6.0"
76-
jsonschema = "^4.17.3"
76+
jsonschema = {version = "^4.18.0a1", allow-prereleases = true}
7777
multidict = {version = "^6.0.4", optional = true}
7878
lazy-object-proxy = "^1.7.1"
7979

tests/integration/conftest.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ def content_from_file(spec_file):
1515

1616

1717
def spec_from_file(spec_file):
18-
spec_dict, spec_url = content_from_file(spec_file)
19-
return Spec.from_dict(spec_dict, spec_url=spec_url)
18+
spec_dict, base_uri = content_from_file(spec_file)
19+
return Spec.from_dict(spec_dict, base_uri=base_uri)
2020

2121

22-
def spec_from_url(spec_url):
23-
content = request.urlopen(spec_url)
22+
def spec_from_url(base_uri):
23+
content = request.urlopen(base_uri)
2424
spec_dict = safe_load(content)
25-
return Spec.from_dict(spec_dict, spec_url=spec_url)
25+
return Spec.from_dict(spec_dict, base_uri=base_uri)
2626

2727

2828
class Factory(dict):
@@ -47,5 +47,5 @@ def v30_petstore_content(factory):
4747

4848
@pytest.fixture(scope="session")
4949
def v30_petstore_spec(v30_petstore_content):
50-
spec_url = "file://tests/integration/data/v3.0/petstore.yaml"
51-
return Spec.from_dict(v30_petstore_content, spec_url=spec_url)
50+
base_uri = "file://tests/integration/data/v3.0/petstore.yaml"
51+
return Spec.from_dict(v30_petstore_content, base_uri=base_uri)

tests/integration/schema/test_spec.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def api_key_encoded(self):
2121
return str(api_key_bytes_enc, "utf8")
2222

2323
@pytest.fixture
24-
def spec_uri(self):
24+
def base_uri(self):
2525
return "file://tests/integration/data/v3.0/petstore.yaml"
2626

2727
@pytest.fixture
@@ -30,9 +30,9 @@ def spec_dict(self, factory):
3030
return content
3131

3232
@pytest.fixture
33-
def spec(self, spec_dict, spec_uri):
33+
def spec(self, spec_dict, base_uri):
3434
return Spec.from_dict(
35-
spec_dict, spec_url=spec_uri, validator=openapi_v30_spec_validator
35+
spec_dict, base_uri=base_uri, validator=openapi_v30_spec_validator
3636
)
3737

3838
@pytest.fixture
@@ -312,7 +312,7 @@ def api_key_encoded(self):
312312
return str(api_key_bytes_enc, "utf8")
313313

314314
@pytest.fixture
315-
def spec_uri(self):
315+
def base_uri(self):
316316
return "file://tests/integration/data/v3.1/webhook-example.yaml"
317317

318318
@pytest.fixture
@@ -323,10 +323,10 @@ def spec_dict(self, factory):
323323
return content
324324

325325
@pytest.fixture
326-
def spec(self, spec_dict, spec_uri):
326+
def spec(self, spec_dict, base_uri):
327327
return Spec.from_dict(
328328
spec_dict,
329-
spec_url=spec_uri,
329+
base_uri=base_uri,
330330
validator=openapi_v31_spec_validator,
331331
)
332332

tests/integration/unmarshalling/test_unmarshallers.py

-2
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,6 @@ def test_basic_type_formats(
265265
@pytest.mark.parametrize(
266266
"type,format,value",
267267
[
268-
("number", "float", 3),
269-
("number", "double", 3),
270268
("string", "date", "test"),
271269
("string", "date-time", "test"),
272270
("string", "uuid", "test"),

0 commit comments

Comments
 (0)