diff --git a/pyproject.toml b/pyproject.toml index da7590a..c3cff29 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ packages = [ [tool.poetry.dependencies] python = "^3.7" tornado = "^4 || ^5 || ^6" -openapi-core = "^0.13.4" +openapi-core = "^0.13.8" ietfparse = "^1.7.0" typing-extensions = "^3.7.4" diff --git a/tests/test_testing.py b/tests/test_testing.py index cf0c6ce..846eb52 100644 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -1,8 +1,9 @@ import json -from openapi_core.schema.responses.exceptions import InvalidResponse # type: ignore +from openapi_core.templating.responses.exceptions import ( # type: ignore + ResponseNotFound, +) import tornado.web # type: ignore - from tornado_openapi3.handler import OpenAPIRequestHandler from tornado_openapi3.testing import AsyncOpenAPITestCase @@ -102,7 +103,7 @@ class IncorrectResponseTests(BaseTestCase): handler.set_status(400) def test_unexpected_response_code(self) -> None: - with self.assertRaises(InvalidResponse) as context: + with self.assertRaises(ResponseNotFound) as context: self.fetch("/resource") self.assertEqual("400", context.exception.http_status) diff --git a/tornado_openapi3/handler.py b/tornado_openapi3/handler.py index fefc856..e0f87eb 100644 --- a/tornado_openapi3/handler.py +++ b/tornado_openapi3/handler.py @@ -7,15 +7,15 @@ from openapi_core.casting.schemas.exceptions import CastError # type: ignore from openapi_core.exceptions import OpenAPIError # type: ignore from openapi_core.deserializing.exceptions import DeserializeError # type: ignore from openapi_core.schema.specs.models import Spec # type: ignore -from openapi_core.schema.media_types.exceptions import ( # type: ignore - InvalidContentType, -) from openapi_core.schema.parameters.exceptions import ( # type: ignore MissingRequiredParameter, ) from openapi_core.schema.request_bodies.exceptions import ( # type: ignore MissingRequestBody, ) +from openapi_core.templating.media_types.exceptions import ( # type: ignore + MediaTypeNotFound, +) from openapi_core.templating.paths.exceptions import ( # type: ignore OperationNotFound, PathNotFound, @@ -115,7 +115,7 @@ class OpenAPIRequestHandler(tornado.web.RequestHandler): |``InvalidSecurity`` |``401`` |Required authorization was missing | | | |from the request. | +-----------------------------+----------+-------------------------------------+ - |``InvalidContentType`` |``415`` |The content type of the request did | + |``MediaTypeNotFound`` |``415`` |The content type of the request did | | | |not match any of the types in the | | | |OpenAPI specification. | +-----------------------------+----------+-------------------------------------+ @@ -152,7 +152,7 @@ class OpenAPIRequestHandler(tornado.web.RequestHandler): self.on_openapi_error(400, e) except InvalidSecurity as e: self.on_openapi_error(401, e) - except InvalidContentType as e: + except MediaTypeNotFound as e: self.on_openapi_error(415, e) except OpenAPIError as e: logger.exception("Unexpected validation failure")