From c81019df96622560378bb306d458064f1c49acb9 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Fri, 20 Nov 2020 12:00:43 -0500 Subject: [PATCH] Add a tornado-specific validator for convenience --- tornado_openapi3/requests.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tornado_openapi3/requests.py b/tornado_openapi3/requests.py index da5ac93..87e35a9 100644 --- a/tornado_openapi3/requests.py +++ b/tornado_openapi3/requests.py @@ -4,6 +4,7 @@ from openapi_core.validation.request.datatypes import ( # type: ignore RequestParameters, OpenAPIRequest, ) +from openapi_core.validation.request import validators # type: ignore from tornado.httputil import HTTPServerRequest from werkzeug.datastructures import ImmutableMultiDict, Headers @@ -34,3 +35,8 @@ class TornadoRequestFactory: "Content-Type", "application/x-www-form-urlencoded" ), ) + + +class RequestValidator(validators.RequestValidator): + def validate(self, request: HTTPServerRequest): + return super().validate(TornadoRequestFactory.create(request))