Upgrade openapi-core to 0.13.8

Handle updated exceptions.
This commit is contained in:
Correl Roush 2021-05-07 14:24:45 -04:00
parent 79e4792d47
commit 8ae5937631
3 changed files with 10 additions and 9 deletions

View file

@ -14,7 +14,7 @@ packages = [
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.7" python = "^3.7"
tornado = "^4 || ^5 || ^6" tornado = "^4 || ^5 || ^6"
openapi-core = "^0.13.4" openapi-core = "^0.13.8"
ietfparse = "^1.7.0" ietfparse = "^1.7.0"
typing-extensions = "^3.7.4" typing-extensions = "^3.7.4"

View file

@ -1,8 +1,9 @@
import json 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 import tornado.web # type: ignore
from tornado_openapi3.handler import OpenAPIRequestHandler from tornado_openapi3.handler import OpenAPIRequestHandler
from tornado_openapi3.testing import AsyncOpenAPITestCase from tornado_openapi3.testing import AsyncOpenAPITestCase
@ -102,7 +103,7 @@ class IncorrectResponseTests(BaseTestCase):
handler.set_status(400) handler.set_status(400)
def test_unexpected_response_code(self) -> None: def test_unexpected_response_code(self) -> None:
with self.assertRaises(InvalidResponse) as context: with self.assertRaises(ResponseNotFound) as context:
self.fetch("/resource") self.fetch("/resource")
self.assertEqual("400", context.exception.http_status) self.assertEqual("400", context.exception.http_status)

View file

@ -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.exceptions import OpenAPIError # type: ignore
from openapi_core.deserializing.exceptions import DeserializeError # 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.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 from openapi_core.schema.parameters.exceptions import ( # type: ignore
MissingRequiredParameter, MissingRequiredParameter,
) )
from openapi_core.schema.request_bodies.exceptions import ( # type: ignore from openapi_core.schema.request_bodies.exceptions import ( # type: ignore
MissingRequestBody, MissingRequestBody,
) )
from openapi_core.templating.media_types.exceptions import ( # type: ignore
MediaTypeNotFound,
)
from openapi_core.templating.paths.exceptions import ( # type: ignore from openapi_core.templating.paths.exceptions import ( # type: ignore
OperationNotFound, OperationNotFound,
PathNotFound, PathNotFound,
@ -115,7 +115,7 @@ class OpenAPIRequestHandler(tornado.web.RequestHandler):
|``InvalidSecurity`` |``401`` |Required authorization was missing | |``InvalidSecurity`` |``401`` |Required authorization was missing |
| | |from the request. | | | |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 | | | |not match any of the types in the |
| | |OpenAPI specification. | | | |OpenAPI specification. |
+-----------------------------+----------+-------------------------------------+ +-----------------------------+----------+-------------------------------------+
@ -152,7 +152,7 @@ class OpenAPIRequestHandler(tornado.web.RequestHandler):
self.on_openapi_error(400, e) self.on_openapi_error(400, e)
except InvalidSecurity as e: except InvalidSecurity as e:
self.on_openapi_error(401, e) self.on_openapi_error(401, e)
except InvalidContentType as e: except MediaTypeNotFound as e:
self.on_openapi_error(415, e) self.on_openapi_error(415, e)
except OpenAPIError as e: except OpenAPIError as e:
logger.exception("Unexpected validation failure") logger.exception("Unexpected validation failure")