Skip to content

Commit f7f97d7

Browse files
authored
Merge pull request #598 from python-openapi/feature/remove-deprecated-features
Remove deprecated features
2 parents 0a885e6 + 41fefb3 commit f7f97d7

30 files changed

+193
-1216
lines changed

Diff for: openapi_core/__init__.py

-20
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,16 @@
1212
from openapi_core.shortcuts import validate_webhook_request
1313
from openapi_core.shortcuts import validate_webhook_response
1414
from openapi_core.spec import Spec
15-
from openapi_core.unmarshalling.request import RequestValidator
1615
from openapi_core.unmarshalling.request import V3RequestUnmarshaller
1716
from openapi_core.unmarshalling.request import V3WebhookRequestUnmarshaller
1817
from openapi_core.unmarshalling.request import V30RequestUnmarshaller
1918
from openapi_core.unmarshalling.request import V31RequestUnmarshaller
2019
from openapi_core.unmarshalling.request import V31WebhookRequestUnmarshaller
21-
from openapi_core.unmarshalling.request import openapi_request_validator
22-
from openapi_core.unmarshalling.request import openapi_v3_request_validator
23-
from openapi_core.unmarshalling.request import openapi_v30_request_validator
24-
from openapi_core.unmarshalling.request import openapi_v31_request_validator
25-
from openapi_core.unmarshalling.response import ResponseValidator
2620
from openapi_core.unmarshalling.response import V3ResponseUnmarshaller
2721
from openapi_core.unmarshalling.response import V3WebhookResponseUnmarshaller
2822
from openapi_core.unmarshalling.response import V30ResponseUnmarshaller
2923
from openapi_core.unmarshalling.response import V31ResponseUnmarshaller
3024
from openapi_core.unmarshalling.response import V31WebhookResponseUnmarshaller
31-
from openapi_core.unmarshalling.response import openapi_response_validator
32-
from openapi_core.unmarshalling.response import openapi_v3_response_validator
33-
from openapi_core.unmarshalling.response import openapi_v30_response_validator
34-
from openapi_core.unmarshalling.response import openapi_v31_response_validator
3525
from openapi_core.validation.request import V3RequestValidator
3626
from openapi_core.validation.request import V3WebhookRequestValidator
3727
from openapi_core.validation.request import V30RequestValidator
@@ -83,14 +73,4 @@
8373
"V3ResponseValidator",
8474
"V3WebhookRequestValidator",
8575
"V3WebhookResponseValidator",
86-
"RequestValidator",
87-
"ResponseValidator",
88-
"openapi_v3_request_validator",
89-
"openapi_v30_request_validator",
90-
"openapi_v31_request_validator",
91-
"openapi_request_validator",
92-
"openapi_v3_response_validator",
93-
"openapi_v30_response_validator",
94-
"openapi_v31_response_validator",
95-
"openapi_response_validator",
9676
]

Diff for: openapi_core/deserializing/media_types/factories.py

-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import warnings
2-
from typing import Dict
31
from typing import Optional
42

53
from openapi_core.deserializing.media_types.datatypes import (
@@ -17,20 +15,10 @@ class MediaTypeDeserializersFactory:
1715
def __init__(
1816
self,
1917
media_type_deserializers: Optional[MediaTypeDeserializersDict] = None,
20-
custom_deserializers: Optional[MediaTypeDeserializersDict] = None,
2118
):
2219
if media_type_deserializers is None:
2320
media_type_deserializers = {}
2421
self.media_type_deserializers = media_type_deserializers
25-
if custom_deserializers is None:
26-
custom_deserializers = {}
27-
else:
28-
warnings.warn(
29-
"custom_deserializers is deprecated. "
30-
"Use extra_media_type_deserializers.",
31-
DeprecationWarning,
32-
)
33-
self.custom_deserializers = custom_deserializers
3422

3523
def create(
3624
self,
@@ -53,8 +41,6 @@ def get_deserializer_callable(
5341
mimetype: str,
5442
extra_media_type_deserializers: MediaTypeDeserializersDict,
5543
) -> Optional[DeserializerCallable]:
56-
if mimetype in self.custom_deserializers:
57-
return self.custom_deserializers[mimetype]
5844
if mimetype in extra_media_type_deserializers:
5945
return extra_media_type_deserializers[mimetype]
6046
return self.media_type_deserializers.get(mimetype)

Diff for: openapi_core/shortcuts.py

-97
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
"""OpenAPI core shortcuts module"""
2-
import warnings
32
from typing import Any
43
from typing import Dict
54
from typing import Optional
65
from typing import Union
76

8-
from lazy_object_proxy import Proxy
9-
107
from openapi_core.exceptions import SpecError
118
from openapi_core.finders import SpecClasses
129
from openapi_core.finders import SpecFinder
@@ -23,9 +20,6 @@
2320
from openapi_core.unmarshalling.request.protocols import (
2421
WebhookRequestUnmarshaller,
2522
)
26-
from openapi_core.unmarshalling.request.proxies import (
27-
SpecRequestValidatorProxy,
28-
)
2923
from openapi_core.unmarshalling.request.types import AnyRequestUnmarshallerType
3024
from openapi_core.unmarshalling.request.types import RequestUnmarshallerType
3125
from openapi_core.unmarshalling.request.types import (
@@ -41,9 +35,6 @@
4135
from openapi_core.unmarshalling.response.protocols import (
4236
WebhookResponseUnmarshaller,
4337
)
44-
from openapi_core.unmarshalling.response.proxies import (
45-
SpecResponseValidatorProxy,
46-
)
4738
from openapi_core.unmarshalling.response.types import (
4839
AnyResponseUnmarshallerType,
4940
)
@@ -287,56 +278,14 @@ def validate_request(
287278
request: AnyRequest,
288279
spec: Spec,
289280
base_url: Optional[str] = None,
290-
validator: Optional[SpecRequestValidatorProxy] = None,
291281
cls: Optional[AnyRequestValidatorType] = None,
292282
**validator_kwargs: Any,
293283
) -> Optional[RequestUnmarshalResult]:
294-
if isinstance(spec, (Request, WebhookRequest)) and isinstance(
295-
request, Spec
296-
):
297-
warnings.warn(
298-
"spec parameter as a first argument is deprecated. "
299-
"Move it to second argument instead.",
300-
DeprecationWarning,
301-
)
302-
request, spec = spec, request
303-
304284
if not isinstance(request, (Request, WebhookRequest)):
305285
raise TypeError("'request' argument is not type of (Webhook)Request")
306286
if not isinstance(spec, Spec):
307287
raise TypeError("'spec' argument is not type of Spec")
308288

309-
if validator is not None and isinstance(request, Request):
310-
warnings.warn(
311-
"validator parameter is deprecated. Use cls instead.",
312-
DeprecationWarning,
313-
)
314-
result = validator.validate(spec, request, base_url=base_url)
315-
result.raise_for_errors()
316-
return result
317-
318-
# redirect to unmarshaller for backward compatibility
319-
if cls is None or issubclass(
320-
cls, (RequestUnmarshaller, WebhookRequestUnmarshaller)
321-
):
322-
result = unmarshal_request(
323-
request,
324-
spec=spec,
325-
base_url=base_url,
326-
cls=cls,
327-
**validator_kwargs,
328-
)
329-
330-
def return_result() -> RequestUnmarshalResult:
331-
warnings.warn(
332-
"validate_request is deprecated for unmarshalling data "
333-
"and it will not return any result in the future. "
334-
"Use unmarshal_request function instead.",
335-
DeprecationWarning,
336-
)
337-
return result
338-
339-
return Proxy(return_result) # type: ignore
340289
if isinstance(request, WebhookRequest):
341290
if cls is None or issubclass(cls, WebhookRequestValidator):
342291
validate_webhook_request(
@@ -370,62 +319,16 @@ def validate_response(
370319
response: Union[Response, Request, WebhookRequest],
371320
spec: Union[Spec, Response],
372321
base_url: Optional[str] = None,
373-
validator: Optional[SpecResponseValidatorProxy] = None,
374322
cls: Optional[AnyResponseValidatorType] = None,
375323
**validator_kwargs: Any,
376324
) -> Optional[ResponseUnmarshalResult]:
377-
if (
378-
isinstance(request, Spec)
379-
and isinstance(response, (Request, WebhookRequest))
380-
and isinstance(spec, Response)
381-
):
382-
warnings.warn(
383-
"spec parameter as a first argument is deprecated. "
384-
"Move it to third argument instead.",
385-
DeprecationWarning,
386-
)
387-
args = request, response, spec
388-
spec, request, response = args
389-
390325
if not isinstance(request, (Request, WebhookRequest)):
391326
raise TypeError("'request' argument is not type of (Webhook)Request")
392327
if not isinstance(response, Response):
393328
raise TypeError("'response' argument is not type of Response")
394329
if not isinstance(spec, Spec):
395330
raise TypeError("'spec' argument is not type of Spec")
396331

397-
if validator is not None and isinstance(request, Request):
398-
warnings.warn(
399-
"validator parameter is deprecated. Use cls instead.",
400-
DeprecationWarning,
401-
)
402-
result = validator.validate(spec, request, response, base_url=base_url)
403-
result.raise_for_errors()
404-
return result
405-
406-
# redirect to unmarshaller for backward compatibility
407-
if cls is None or issubclass(
408-
cls, (ResponseUnmarshaller, WebhookResponseUnmarshaller)
409-
):
410-
result = unmarshal_response(
411-
request,
412-
response,
413-
spec=spec,
414-
base_url=base_url,
415-
cls=cls,
416-
**validator_kwargs,
417-
)
418-
419-
def return_result() -> ResponseUnmarshalResult:
420-
warnings.warn(
421-
"validate_response is deprecated for unmarshalling data "
422-
"and it will not return any result in the future. "
423-
"Use unmarshal_response function instead.",
424-
DeprecationWarning,
425-
)
426-
return result
427-
428-
return Proxy(return_result) # type: ignore
429332
if isinstance(request, WebhookRequest):
430333
if cls is None or issubclass(cls, WebhookResponseValidator):
431334
validate_webhook_response(

Diff for: openapi_core/spec/paths.py

-29
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,18 @@
1-
import warnings
21
from typing import Any
3-
from typing import Dict
42
from typing import Hashable
53
from typing import Mapping
6-
from typing import Optional
74
from typing import Type
85
from typing import TypeVar
96

107
from jsonschema_spec import SchemaPath
11-
from jsonschema_spec import default_handlers
128
from openapi_spec_validator.validation import openapi_spec_validator_proxy
13-
from openapi_spec_validator.validation.protocols import SupportsValidation
149

1510
TSpec = TypeVar("TSpec", bound="Spec")
1611

1712
SPEC_SEPARATOR = "#"
1813

1914

2015
class Spec(SchemaPath):
21-
@classmethod
22-
def create(
23-
cls: Type[TSpec],
24-
data: Mapping[Hashable, Any],
25-
*args: Any,
26-
url: str = "",
27-
ref_resolver_handlers: Dict[str, Any] = default_handlers,
28-
separator: str = SPEC_SEPARATOR,
29-
validator: Optional[SupportsValidation] = openapi_spec_validator_proxy,
30-
) -> TSpec:
31-
warnings.warn(
32-
"Spec.create method is deprecated. Use Spec.from_dict instead.",
33-
DeprecationWarning,
34-
)
35-
36-
return cls.from_dict(
37-
data,
38-
*args,
39-
spec_url=url,
40-
ref_resolver_handlers=ref_resolver_handlers,
41-
separator=separator,
42-
validator=validator,
43-
)
44-
4516
@classmethod
4617
def from_dict(
4718
cls: Type[TSpec],

Diff for: openapi_core/spec/shortcuts.py

-36
This file was deleted.

Diff for: openapi_core/unmarshalling/request/__init__.py

+2-46
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
"""OpenAPI core unmarshalling request module"""
2-
from openapi_core.unmarshalling.request.proxies import (
3-
DetectSpecRequestValidatorProxy,
4-
)
5-
from openapi_core.unmarshalling.request.proxies import (
6-
SpecRequestValidatorProxy,
7-
)
8-
from openapi_core.unmarshalling.request.unmarshallers import (
9-
APICallRequestUnmarshaller,
10-
)
11-
from openapi_core.unmarshalling.request.unmarshallers import RequestValidator
122
from openapi_core.unmarshalling.request.unmarshallers import (
133
V30RequestUnmarshaller,
144
)
@@ -18,49 +8,15 @@
188
from openapi_core.unmarshalling.request.unmarshallers import (
199
V31WebhookRequestUnmarshaller,
2010
)
21-
from openapi_core.unmarshalling.schemas import (
22-
oas30_write_schema_unmarshallers_factory,
23-
)
24-
from openapi_core.unmarshalling.schemas import (
25-
oas31_schema_unmarshallers_factory,
26-
)
2711

2812
__all__ = [
13+
"V3RequestUnmarshaller",
14+
"V3WebhookRequestUnmarshaller",
2915
"V30RequestUnmarshaller",
3016
"V31RequestUnmarshaller",
3117
"V31WebhookRequestUnmarshaller",
32-
"RequestValidator",
33-
"openapi_v30_request_validator",
34-
"openapi_v31_request_validator",
35-
"openapi_v3_request_validator",
36-
"openapi_request_validator",
3718
]
3819

3920
# alias to the latest v3 version
4021
V3RequestUnmarshaller = V31RequestUnmarshaller
4122
V3WebhookRequestUnmarshaller = V31WebhookRequestUnmarshaller
42-
43-
# spec validators
44-
openapi_v30_request_validator = SpecRequestValidatorProxy(
45-
APICallRequestUnmarshaller,
46-
schema_unmarshallers_factory=oas30_write_schema_unmarshallers_factory,
47-
deprecated="openapi_v30_request_validator",
48-
use="V30RequestValidator",
49-
)
50-
openapi_v31_request_validator = SpecRequestValidatorProxy(
51-
APICallRequestUnmarshaller,
52-
schema_unmarshallers_factory=oas31_schema_unmarshallers_factory,
53-
deprecated="openapi_v31_request_validator",
54-
use="V31RequestValidator",
55-
)
56-
57-
# spec validators alias to the latest v3 version
58-
openapi_v3_request_validator = openapi_v31_request_validator
59-
60-
# detect version spec
61-
openapi_request_validator = DetectSpecRequestValidatorProxy(
62-
{
63-
("openapi", "3.0"): openapi_v30_request_validator,
64-
("openapi", "3.1"): openapi_v31_request_validator,
65-
},
66-
)

0 commit comments

Comments
 (0)