Skip to content

Commit 18cace2

Browse files
committed
openapi-spec-validator remove deprecations
1 parent 4054861 commit 18cace2

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

Diff for: openapi_core/spec/paths.py

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import warnings
12
from typing import Any
23
from typing import Hashable
34
from typing import Mapping
45
from typing import Type
56
from typing import TypeVar
67

78
from jsonschema_spec import SchemaPath
9+
from openapi_spec_validator import validate_spec
810
from openapi_spec_validator.validation import openapi_spec_validator_proxy
911

1012
TSpec = TypeVar("TSpec", bound="Spec")
@@ -20,11 +22,32 @@ def from_dict(
2022
*args: Any,
2123
**kwargs: Any,
2224
) -> TSpec:
25+
if "validator" in kwargs:
2326
validator = kwargs.pop("validator", openapi_spec_validator_proxy)
2427
if validator is not None:
28+
warnings.warn(
29+
"validator parameter is deprecated. "
30+
"Use spec_validator_cls instead.",
31+
DeprecationWarning,
32+
)
2533
base_uri = kwargs.get("base_uri", "")
2634
spec_url = kwargs.get("spec_url")
27-
validator.validate(data, base_uri=base_uri, spec_url=spec_url)
35+
validate_spec(
36+
data,
37+
base_uri=base_uri,
38+
spec_url=spec_url,
39+
validator=validator,
40+
)
41+
elif "spec_validator_cls" not in kwargs or kwargs["spec_validator_cls"] is not None:
42+
spec_validator_cls = kwargs.pop("spec_validator_cls", None)
43+
base_uri = kwargs.get("base_uri", "")
44+
spec_url = kwargs.get("spec_url")
45+
validate_spec(
46+
data,
47+
base_uri=base_uri,
48+
spec_url=spec_url,
49+
cls=spec_validator_cls,
50+
)
2851

2952
return super().from_dict(data, *args, **kwargs)
3053

Diff for: tests/unit/conftest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
@pytest.fixture
77
def spec_v30():
8-
return Spec.from_dict({"openapi": "3.0"}, validator=None)
8+
return Spec.from_dict({"openapi": "3.0.0"}, validator=None)
99

1010

1111
@pytest.fixture
1212
def spec_v31():
13-
return Spec.from_dict({"openapi": "3.1"}, validator=None)
13+
return Spec.from_dict({"openapi": "3.1.0"}, validator=None)
1414

1515

1616
@pytest.fixture

0 commit comments

Comments
 (0)