Skip to content

Commit

Permalink
Merge pull request #718 from python-openapi/feature/merge-stable-0.18.x
Browse files Browse the repository at this point in the history
Feature/merge stable 0.18.x
  • Loading branch information
p1c2u committed Nov 6, 2023
2 parents 06d768f + 41cda52 commit 8717ddf
Show file tree
Hide file tree
Showing 10 changed files with 637 additions and 552 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.18.1
current_version = 0.18.2
tag = True
tag_name = {new_version}
commit = True
Expand Down
2 changes: 1 addition & 1 deletion openapi_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

__author__ = "Artur Maciag"
__email__ = "maciag.artur@gmail.com"
__version__ = "0.18.1"
__version__ = "0.18.2"
__url__ = "https://github.com/python-openapi/openapi-core"
__license__ = "BSD 3-Clause License"

Expand Down
24 changes: 18 additions & 6 deletions openapi_core/spec/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from typing import Type
from typing import TypeVar

from jsonschema.validators import _UNSET
from jsonschema_path import SchemaPath
from openapi_spec_validator.validation import openapi_spec_validator_proxy
from openapi_spec_validator import validate

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

Expand All @@ -25,10 +26,21 @@ def from_dict(
"Spec is deprecated. Use SchemaPath from jsonschema-path package.",
DeprecationWarning,
)
validator = kwargs.pop("validator", openapi_spec_validator_proxy)
if validator is not None:
base_uri = kwargs.get("base_uri", "")
spec_url = kwargs.get("spec_url")
validator.validate(data, base_uri=base_uri, spec_url=spec_url)
if "validator" in kwargs:
warnings.warn(
"validator parameter is deprecated. Use spec_validator_cls instead.",
DeprecationWarning,
)
validator = kwargs.pop("validator", _UNSET)
spec_validator_cls = kwargs.pop("spec_validator_cls", _UNSET)
base_uri = kwargs.get("base_uri", "")
spec_url = kwargs.get("spec_url")
if spec_validator_cls is not None:
if spec_validator_cls is not _UNSET:
validate(data, base_uri=base_uri, cls=spec_validator_cls)
elif validator is _UNSET:
validate(data, base_uri=base_uri)
elif validator is not None:
validator.validate(data, base_uri=base_uri, spec_url=spec_url)

return super().from_dict(data, *args, **kwargs)
913 changes: 458 additions & 455 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ignore_missing_imports = true

[tool.poetry]
name = "openapi-core"
version = "0.18.1"
version = "0.18.2"
description = "client-side and server-side support for the OpenAPI Specification v3"
authors = ["Artur Maciag <maciag.artur@gmail.com>"]
license = "BSD-3-Clause"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@

USE_I18N = True

USE_L10N = True

USE_TZ = True


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def test_response_validator_path_pattern(self, response_unmarshaller):
"http://localhost/browse/12/?q=string",
json={"data": "data"},
status=200,
match_querystring=True,
headers={"X-Rate-Limit": "12"},
)
request = requests.Request(
Expand Down
210 changes: 129 additions & 81 deletions tests/integration/test_petstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,14 @@ def test_get_pets(self, spec):
args=query_params,
)

result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)
with pytest.warns(
DeprecationWarning, match="limit parameter is deprecated"
):
result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)

assert result.parameters == Parameters(
query={
Expand Down Expand Up @@ -154,11 +157,14 @@ def test_get_pets_response(self, spec):
args=query_params,
)

result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)
with pytest.warns(
DeprecationWarning, match="limit parameter is deprecated"
):
result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)

assert result.parameters == Parameters(
query={
Expand Down Expand Up @@ -211,11 +217,14 @@ def test_get_pets_response_media_type(self, spec):
args=query_params,
)

result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)
with pytest.warns(
DeprecationWarning, match="limit parameter is deprecated"
):
result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)

assert result.parameters == Parameters(
query={
Expand Down Expand Up @@ -256,11 +265,14 @@ def test_get_pets_invalid_response(self, spec, response_unmarshaller):
args=query_params,
)

result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)
with pytest.warns(
DeprecationWarning, match="limit parameter is deprecated"
):
result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)

assert result.parameters == Parameters(
query={
Expand Down Expand Up @@ -325,11 +337,14 @@ def test_get_pets_ids_param(self, spec):
args=query_params,
)

result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)
with pytest.warns(
DeprecationWarning, match="limit parameter is deprecated"
):
result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)

assert result.parameters == Parameters(
query={
Expand Down Expand Up @@ -374,11 +389,14 @@ def test_get_pets_tags_param(self, spec):
args=query_params,
)

result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)
with pytest.warns(
DeprecationWarning, match="limit parameter is deprecated"
):
result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)

assert result.parameters == Parameters(
query={
Expand Down Expand Up @@ -423,12 +441,15 @@ def test_get_pets_parameter_schema_error(self, spec):
args=query_params,
)

with pytest.raises(ParameterValidationError) as exc_info:
validate_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)
with pytest.warns(
DeprecationWarning, match="limit parameter is deprecated"
):
with pytest.raises(ParameterValidationError) as exc_info:
validate_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)
assert type(exc_info.value.__cause__) is InvalidSchemaValue

result = unmarshal_request(
Expand All @@ -452,12 +473,15 @@ def test_get_pets_wrong_parameter_type(self, spec):
args=query_params,
)

with pytest.raises(ParameterValidationError) as exc_info:
validate_request(
request,
spec=spec,
cls=V30RequestParametersValidator,
)
with pytest.warns(
DeprecationWarning, match="limit parameter is deprecated"
):
with pytest.raises(ParameterValidationError) as exc_info:
validate_request(
request,
spec=spec,
cls=V30RequestParametersValidator,
)
assert type(exc_info.value.__cause__) is CastError

result = unmarshal_request(
Expand All @@ -476,12 +500,15 @@ def test_get_pets_raises_missing_required_param(self, spec):
path_pattern=path_pattern,
)

with pytest.raises(MissingRequiredParameter):
validate_request(
request,
spec=spec,
cls=V30RequestParametersValidator,
)
with pytest.warns(
DeprecationWarning, match="limit parameter is deprecated"
):
with pytest.raises(MissingRequiredParameter):
validate_request(
request,
spec=spec,
cls=V30RequestParametersValidator,
)

result = unmarshal_request(
request, spec=spec, cls=V30RequestBodyUnmarshaller
Expand All @@ -505,12 +532,15 @@ def test_get_pets_empty_value(self, spec):
args=query_params,
)

with pytest.raises(ParameterValidationError) as exc_info:
validate_request(
request,
spec=spec,
cls=V30RequestParametersValidator,
)
with pytest.warns(
DeprecationWarning, match="limit parameter is deprecated"
):
with pytest.raises(ParameterValidationError) as exc_info:
validate_request(
request,
spec=spec,
cls=V30RequestParametersValidator,
)
assert type(exc_info.value.__cause__) is EmptyQueryParameterValue

result = unmarshal_request(
Expand All @@ -535,11 +565,14 @@ def test_get_pets_allow_empty_value(self, spec):
args=query_params,
)

result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)
with pytest.warns(
DeprecationWarning, match="limit parameter is deprecated"
):
result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)

assert result.parameters == Parameters(
query={
Expand Down Expand Up @@ -570,11 +603,14 @@ def test_get_pets_none_value(self, spec):
args=query_params,
)

result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)
with pytest.warns(
DeprecationWarning, match="limit parameter is deprecated"
):
result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)

assert result.parameters == Parameters(
query={
Expand Down Expand Up @@ -606,11 +642,14 @@ def test_get_pets_param_order(self, spec):
args=query_params,
)

result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)
with pytest.warns(
DeprecationWarning, match="limit parameter is deprecated"
):
result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)

assert result.parameters == Parameters(
query={
Expand Down Expand Up @@ -647,11 +686,14 @@ def test_get_pets_param_coordinates(self, spec):
args=query_params,
)

result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)
with pytest.warns(
DeprecationWarning, match="limit parameter is deprecated"
):
result = unmarshal_request(
request,
spec=spec,
cls=V30RequestParametersUnmarshaller,
)

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

response_result = unmarshal_response(request, response, spec=spec)
with pytest.warns(
DeprecationWarning, match="x-delete-confirm header is deprecated"
):
response_result = unmarshal_response(request, response, spec=spec)
assert response_result.errors == []
assert response_result.data is None

result = unmarshal_response(
request,
response,
spec=spec,
cls=V30ResponseHeadersUnmarshaller,
)
with pytest.warns(
DeprecationWarning, match="x-delete-confirm header is deprecated"
):
result = unmarshal_response(
request,
response,
spec=spec,
cls=V30ResponseHeadersUnmarshaller,
)

assert result.headers == {
"x-delete-confirm": True,
Expand Down

0 comments on commit 8717ddf

Please sign in to comment.