Skip to content

Feature/merge stable 0.18.x #718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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__ = "[email protected]"
__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 <[email protected]>"]
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
Loading