diff --git a/examples/openapi3.py b/examples/openapi3.py index 51b9107..849fd2c 100644 --- a/examples/openapi3.py +++ b/examples/openapi3.py @@ -82,6 +82,7 @@ def cors_response(req, res): @app.before_response() def before_each_response(req): """Check API before process each response.""" + log.warn("BEFORE") req.api = OpenAPIRequest(req) try: unmarshal_request(req.api, app.openapi_spec) @@ -100,9 +101,14 @@ def before_each_response(req): @app.after_response() def after_each_response(req, res): """Check if ansewer is valid by OpenAPI.""" + log.warn("AFTER") if not hasattr(req, "api"): req.api = OpenAPIRequest(req) try: + log.error("X type of request: %s", type(req)) + log.error("X mro of request: %s", type(req).__mro__) + log.error("X type of request: %s", type(req.api)) + log.error("X mro of request: %s", type(req.api).__mro__) unmarshal_response( req.api, OpenAPIResponse(res), diff --git a/poorwsgi/openapi_wrapper.py b/poorwsgi/openapi_wrapper.py index ffdf9b7..ff1fd8d 100644 --- a/poorwsgi/openapi_wrapper.py +++ b/poorwsgi/openapi_wrapper.py @@ -6,6 +6,7 @@ :Classes: OpenAPIRequest, OpenAPIResponse """ from collections import OrderedDict +import logging import re @@ -13,7 +14,7 @@ from openapi_core.validation.request.datatypes import RequestParameters -class OpenAPIRequest(Request): +class OpenAPIRequest(): """Wrapper of PoorWSGI request to OpenAPIRequest. Be careful with testing of big incoming request body property, which @@ -29,21 +30,25 @@ def __init__(self, request): @property def host_url(self): """Return host_url for validator.""" + logging.warning("-> host_url") return self.request.construct_url('') @property def path(self): """Return method path""" + logging.warning("-> path") return self.request.path @property def method(self): """Return method in lower case for validator.""" + logging.warning("-> method") return self.request.method.lower() @property def full_url_pattern(self): """Return full_url_pattern for validator.""" + logging.warning("-> full_url_pattern") if self.request.uri_rule is None: return self.host_url+self.request.uri return self.host_url+OpenAPIRequest.re_pattern.sub( @@ -52,6 +57,7 @@ def full_url_pattern(self): @property def parameters(self): """Return RequestParameters object for validator.""" + logging.warning("-> parameters") path_args = OrderedDict() for (key, val) in self.request.path_args.items(): # allowed openapi core types... @@ -70,11 +76,13 @@ def parameters(self): @property def body(self): """Return request data for validator.""" + logging.warning("-> body") return self.request.data @property def mimetype(self): """Return request mime_type for validator.""" + logging.warning("-> mime_type") return self.request.mime_type diff --git a/tests_integrity/test_openapi.py b/tests_integrity/test_openapi.py index 2d013ec..b2430c2 100644 --- a/tests_integrity/test_openapi.py +++ b/tests_integrity/test_openapi.py @@ -85,6 +85,7 @@ def test_json_post_unicode(self, url): method="POST", json=data, response_spec=SPEC) assert res.json()["request"] == data + assert False def test_json_post_unicode_struct(self, url): data = {"city": "Česká Lípa"}