Skip to content

Commit 8717ddf

Browse files
authored
Merge pull request #718 from python-openapi/feature/merge-stable-0.18.x
Feature/merge stable 0.18.x
2 parents 06d768f + 41cda52 commit 8717ddf

File tree

10 files changed

+637
-552
lines changed

10 files changed

+637
-552
lines changed

.bumpversion.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.18.1
2+
current_version = 0.18.2
33
tag = True
44
tag_name = {new_version}
55
commit = True

openapi_core/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
__author__ = "Artur Maciag"
3737
__email__ = "[email protected]"
38-
__version__ = "0.18.1"
38+
__version__ = "0.18.2"
3939
__url__ = "https://github.com/python-openapi/openapi-core"
4040
__license__ = "BSD 3-Clause License"
4141

openapi_core/spec/paths.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
from typing import Type
66
from typing import TypeVar
77

8+
from jsonschema.validators import _UNSET
89
from jsonschema_path import SchemaPath
9-
from openapi_spec_validator.validation import openapi_spec_validator_proxy
10+
from openapi_spec_validator import validate
1011

1112
TSpec = TypeVar("TSpec", bound="Spec")
1213

@@ -25,10 +26,21 @@ def from_dict(
2526
"Spec is deprecated. Use SchemaPath from jsonschema-path package.",
2627
DeprecationWarning,
2728
)
28-
validator = kwargs.pop("validator", openapi_spec_validator_proxy)
29-
if validator is not None:
30-
base_uri = kwargs.get("base_uri", "")
31-
spec_url = kwargs.get("spec_url")
32-
validator.validate(data, base_uri=base_uri, spec_url=spec_url)
29+
if "validator" in kwargs:
30+
warnings.warn(
31+
"validator parameter is deprecated. Use spec_validator_cls instead.",
32+
DeprecationWarning,
33+
)
34+
validator = kwargs.pop("validator", _UNSET)
35+
spec_validator_cls = kwargs.pop("spec_validator_cls", _UNSET)
36+
base_uri = kwargs.get("base_uri", "")
37+
spec_url = kwargs.get("spec_url")
38+
if spec_validator_cls is not None:
39+
if spec_validator_cls is not _UNSET:
40+
validate(data, base_uri=base_uri, cls=spec_validator_cls)
41+
elif validator is _UNSET:
42+
validate(data, base_uri=base_uri)
43+
elif validator is not None:
44+
validator.validate(data, base_uri=base_uri, spec_url=spec_url)
3345

3446
return super().from_dict(data, *args, **kwargs)

poetry.lock

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

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ignore_missing_imports = true
3333

3434
[tool.poetry]
3535
name = "openapi-core"
36-
version = "0.18.1"
36+
version = "0.18.2"
3737
description = "client-side and server-side support for the OpenAPI Specification v3"
3838
authors = ["Artur Maciag <[email protected]>"]
3939
license = "BSD-3-Clause"

tests/integration/contrib/django/data/v3.0/djangoproject/settings.py

-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@
102102

103103
USE_I18N = True
104104

105-
USE_L10N = True
106-
107105
USE_TZ = True
108106

109107

tests/integration/contrib/requests/test_requests_validation.py

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def test_response_validator_path_pattern(self, response_unmarshaller):
4444
"http://localhost/browse/12/?q=string",
4545
json={"data": "data"},
4646
status=200,
47-
match_querystring=True,
4847
headers={"X-Rate-Limit": "12"},
4948
)
5049
request = requests.Request(

tests/integration/test_petstore.py

+129-81
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,14 @@ def test_get_pets(self, spec):
9898
args=query_params,
9999
)
100100

101-
result = unmarshal_request(
102-
request,
103-
spec=spec,
104-
cls=V30RequestParametersUnmarshaller,
105-
)
101+
with pytest.warns(
102+
DeprecationWarning, match="limit parameter is deprecated"
103+
):
104+
result = unmarshal_request(
105+
request,
106+
spec=spec,
107+
cls=V30RequestParametersUnmarshaller,
108+
)
106109

107110
assert result.parameters == Parameters(
108111
query={
@@ -154,11 +157,14 @@ def test_get_pets_response(self, spec):
154157
args=query_params,
155158
)
156159

157-
result = unmarshal_request(
158-
request,
159-
spec=spec,
160-
cls=V30RequestParametersUnmarshaller,
161-
)
160+
with pytest.warns(
161+
DeprecationWarning, match="limit parameter is deprecated"
162+
):
163+
result = unmarshal_request(
164+
request,
165+
spec=spec,
166+
cls=V30RequestParametersUnmarshaller,
167+
)
162168

163169
assert result.parameters == Parameters(
164170
query={
@@ -211,11 +217,14 @@ def test_get_pets_response_media_type(self, spec):
211217
args=query_params,
212218
)
213219

214-
result = unmarshal_request(
215-
request,
216-
spec=spec,
217-
cls=V30RequestParametersUnmarshaller,
218-
)
220+
with pytest.warns(
221+
DeprecationWarning, match="limit parameter is deprecated"
222+
):
223+
result = unmarshal_request(
224+
request,
225+
spec=spec,
226+
cls=V30RequestParametersUnmarshaller,
227+
)
219228

220229
assert result.parameters == Parameters(
221230
query={
@@ -256,11 +265,14 @@ def test_get_pets_invalid_response(self, spec, response_unmarshaller):
256265
args=query_params,
257266
)
258267

259-
result = unmarshal_request(
260-
request,
261-
spec=spec,
262-
cls=V30RequestParametersUnmarshaller,
263-
)
268+
with pytest.warns(
269+
DeprecationWarning, match="limit parameter is deprecated"
270+
):
271+
result = unmarshal_request(
272+
request,
273+
spec=spec,
274+
cls=V30RequestParametersUnmarshaller,
275+
)
264276

265277
assert result.parameters == Parameters(
266278
query={
@@ -325,11 +337,14 @@ def test_get_pets_ids_param(self, spec):
325337
args=query_params,
326338
)
327339

328-
result = unmarshal_request(
329-
request,
330-
spec=spec,
331-
cls=V30RequestParametersUnmarshaller,
332-
)
340+
with pytest.warns(
341+
DeprecationWarning, match="limit parameter is deprecated"
342+
):
343+
result = unmarshal_request(
344+
request,
345+
spec=spec,
346+
cls=V30RequestParametersUnmarshaller,
347+
)
333348

334349
assert result.parameters == Parameters(
335350
query={
@@ -374,11 +389,14 @@ def test_get_pets_tags_param(self, spec):
374389
args=query_params,
375390
)
376391

377-
result = unmarshal_request(
378-
request,
379-
spec=spec,
380-
cls=V30RequestParametersUnmarshaller,
381-
)
392+
with pytest.warns(
393+
DeprecationWarning, match="limit parameter is deprecated"
394+
):
395+
result = unmarshal_request(
396+
request,
397+
spec=spec,
398+
cls=V30RequestParametersUnmarshaller,
399+
)
382400

383401
assert result.parameters == Parameters(
384402
query={
@@ -423,12 +441,15 @@ def test_get_pets_parameter_schema_error(self, spec):
423441
args=query_params,
424442
)
425443

426-
with pytest.raises(ParameterValidationError) as exc_info:
427-
validate_request(
428-
request,
429-
spec=spec,
430-
cls=V30RequestParametersUnmarshaller,
431-
)
444+
with pytest.warns(
445+
DeprecationWarning, match="limit parameter is deprecated"
446+
):
447+
with pytest.raises(ParameterValidationError) as exc_info:
448+
validate_request(
449+
request,
450+
spec=spec,
451+
cls=V30RequestParametersUnmarshaller,
452+
)
432453
assert type(exc_info.value.__cause__) is InvalidSchemaValue
433454

434455
result = unmarshal_request(
@@ -452,12 +473,15 @@ def test_get_pets_wrong_parameter_type(self, spec):
452473
args=query_params,
453474
)
454475

455-
with pytest.raises(ParameterValidationError) as exc_info:
456-
validate_request(
457-
request,
458-
spec=spec,
459-
cls=V30RequestParametersValidator,
460-
)
476+
with pytest.warns(
477+
DeprecationWarning, match="limit parameter is deprecated"
478+
):
479+
with pytest.raises(ParameterValidationError) as exc_info:
480+
validate_request(
481+
request,
482+
spec=spec,
483+
cls=V30RequestParametersValidator,
484+
)
461485
assert type(exc_info.value.__cause__) is CastError
462486

463487
result = unmarshal_request(
@@ -476,12 +500,15 @@ def test_get_pets_raises_missing_required_param(self, spec):
476500
path_pattern=path_pattern,
477501
)
478502

479-
with pytest.raises(MissingRequiredParameter):
480-
validate_request(
481-
request,
482-
spec=spec,
483-
cls=V30RequestParametersValidator,
484-
)
503+
with pytest.warns(
504+
DeprecationWarning, match="limit parameter is deprecated"
505+
):
506+
with pytest.raises(MissingRequiredParameter):
507+
validate_request(
508+
request,
509+
spec=spec,
510+
cls=V30RequestParametersValidator,
511+
)
485512

486513
result = unmarshal_request(
487514
request, spec=spec, cls=V30RequestBodyUnmarshaller
@@ -505,12 +532,15 @@ def test_get_pets_empty_value(self, spec):
505532
args=query_params,
506533
)
507534

508-
with pytest.raises(ParameterValidationError) as exc_info:
509-
validate_request(
510-
request,
511-
spec=spec,
512-
cls=V30RequestParametersValidator,
513-
)
535+
with pytest.warns(
536+
DeprecationWarning, match="limit parameter is deprecated"
537+
):
538+
with pytest.raises(ParameterValidationError) as exc_info:
539+
validate_request(
540+
request,
541+
spec=spec,
542+
cls=V30RequestParametersValidator,
543+
)
514544
assert type(exc_info.value.__cause__) is EmptyQueryParameterValue
515545

516546
result = unmarshal_request(
@@ -535,11 +565,14 @@ def test_get_pets_allow_empty_value(self, spec):
535565
args=query_params,
536566
)
537567

538-
result = unmarshal_request(
539-
request,
540-
spec=spec,
541-
cls=V30RequestParametersUnmarshaller,
542-
)
568+
with pytest.warns(
569+
DeprecationWarning, match="limit parameter is deprecated"
570+
):
571+
result = unmarshal_request(
572+
request,
573+
spec=spec,
574+
cls=V30RequestParametersUnmarshaller,
575+
)
543576

544577
assert result.parameters == Parameters(
545578
query={
@@ -570,11 +603,14 @@ def test_get_pets_none_value(self, spec):
570603
args=query_params,
571604
)
572605

573-
result = unmarshal_request(
574-
request,
575-
spec=spec,
576-
cls=V30RequestParametersUnmarshaller,
577-
)
606+
with pytest.warns(
607+
DeprecationWarning, match="limit parameter is deprecated"
608+
):
609+
result = unmarshal_request(
610+
request,
611+
spec=spec,
612+
cls=V30RequestParametersUnmarshaller,
613+
)
578614

579615
assert result.parameters == Parameters(
580616
query={
@@ -606,11 +642,14 @@ def test_get_pets_param_order(self, spec):
606642
args=query_params,
607643
)
608644

609-
result = unmarshal_request(
610-
request,
611-
spec=spec,
612-
cls=V30RequestParametersUnmarshaller,
613-
)
645+
with pytest.warns(
646+
DeprecationWarning, match="limit parameter is deprecated"
647+
):
648+
result = unmarshal_request(
649+
request,
650+
spec=spec,
651+
cls=V30RequestParametersUnmarshaller,
652+
)
614653

615654
assert result.parameters == Parameters(
616655
query={
@@ -647,11 +686,14 @@ def test_get_pets_param_coordinates(self, spec):
647686
args=query_params,
648687
)
649688

650-
result = unmarshal_request(
651-
request,
652-
spec=spec,
653-
cls=V30RequestParametersUnmarshaller,
654-
)
689+
with pytest.warns(
690+
DeprecationWarning, match="limit parameter is deprecated"
691+
):
692+
result = unmarshal_request(
693+
request,
694+
spec=spec,
695+
cls=V30RequestParametersUnmarshaller,
696+
)
655697

656698
assert is_dataclass(result.parameters.query["coordinates"])
657699
assert (
@@ -1948,16 +1990,22 @@ def test_delete_tags_with_requestbody(self, spec):
19481990
}
19491991
response = MockResponse(data, status_code=200, headers=headers)
19501992

1951-
response_result = unmarshal_response(request, response, spec=spec)
1993+
with pytest.warns(
1994+
DeprecationWarning, match="x-delete-confirm header is deprecated"
1995+
):
1996+
response_result = unmarshal_response(request, response, spec=spec)
19521997
assert response_result.errors == []
19531998
assert response_result.data is None
19541999

1955-
result = unmarshal_response(
1956-
request,
1957-
response,
1958-
spec=spec,
1959-
cls=V30ResponseHeadersUnmarshaller,
1960-
)
2000+
with pytest.warns(
2001+
DeprecationWarning, match="x-delete-confirm header is deprecated"
2002+
):
2003+
result = unmarshal_response(
2004+
request,
2005+
response,
2006+
spec=spec,
2007+
cls=V30ResponseHeadersUnmarshaller,
2008+
)
19612009

19622010
assert result.headers == {
19632011
"x-delete-confirm": True,

0 commit comments

Comments
 (0)