docs: def validate(request_schema=None, response_schema=None):
      """
      Decorate request handler to make it automagically validate it's request
      and response.
      """
      def wrapper(func):
          # Validating the schemas itself.
          # Die with exception if they aren't valid
          if request_schema is not None:
              _request_schema_validator = validator_for(request_schema)
              _request_schema_validator.check_schema(request_schema)
  
          if response_schema is not None:
              _response_schema_validator = validator_for(response_schema)
              _response_schema_validator.check_schema(response_schema)
  
          @asyncio.coroutine
          @functools.wraps(func)
          def wrapped(*args):
              if asyncio.iscoroutinefunction(func):
                  coro = func
              else:
                  coro = asyncio.coroutine(func)
  
              # Supports class based views see web.View
              if isinstance(args[0], AbstractView):
                  class_based = True
                  request = args[0].request
              else:
                  class_based = False
                  request = args[-1]
  
              # Strictly expect json object here
              try:
                  req_body = yield from request.json()
              except (json.decoder.JSONDecodeError, TypeError):
                  _raise_exception(
                      web.HTTPBadRequest,
                      "Request is malformed; could not decode JSON object.")
  
              # Validate request data against request schema (if given)
              if request_schema is not None:
                  _validate_data(req_body, request_schema,
                                 _request_schema_validator)
  
              coro_args = req_body, request
              if class_based:
                  coro_args = (args[0], ) + coro_args
  
              context = yield from coro(*coro_args)
  
              # No validation of response for websockets stream
              if isinstance(context, web.StreamResponse):
                  return context
  
              # Validate response data against response schema (if given)
              if response_schema is not None:
                  _validate_data(context, response_schema,
                                 _response_schema_validator)
  
              try:
                  return web.json_response(context)
              except (TypeError, ):
                  _raise_exception(
                      web.HTTPInternalServerError,
                      "Response is malformed; could not encode JSON object.")
  
          # Store schemas in wrapped handlers, so it later can be reused
          setattr(wrapped, "_request_schema", request_schema)
          setattr(wrapped, "_response_schema", response_schema)
          return wrapped
      return wrapper