def validate(input_schema=None, output_schema=None,<EOL>input_example=None, output_example=None,<EOL>validator_cls=None,<EOL>format_checker=None, on_empty_404=False,<EOL>use_defaults=False):
@container<EOL>def _validate(rh_method):<EOL><INDENT>"""<STR_LIT>"""<EOL>@wraps(rh_method)<EOL>@tornado.gen.coroutine<EOL>def _wrapper(self, *args, **kwargs):<EOL><INDENT>if input_schema is not None:<EOL><INDENT>try:<EOL><INDENT>encoding = "<STR_LIT>"<EOL>input_ = json.loads(self.request.body.decode(encoding))<EOL><DEDENT>except ValueError as e:<EOL><INDENT>raise jsonschema.ValidationError(<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>if use_defaults:<EOL><INDENT>input_ = input_schema_clean(input_, input_schema)<EOL><DEDENT>jsonschema.validate(<EOL>input_,<EOL>input_schema,<EOL>cls=validator_cls,<EOL>format_checker=format_checker<EOL>)<EOL><DEDENT>else:<EOL><INDENT>input_ = None<EOL><DEDENT>setattr(self, "<STR_LIT:body>", input_)<EOL>output = rh_method(self, *args, **kwargs)<EOL>if is_future(output):<EOL><INDENT>output = yield output<EOL><DEDENT>if not output and on_empty_404:<EOL><INDENT>raise APIError(<NUM_LIT>, "<STR_LIT>")<EOL><DEDENT>if output_schema is not None:<EOL><INDENT>try:<EOL><INDENT>jsonschema.validate(<EOL>{"<STR_LIT:result>": output},<EOL>{<EOL>"<STR_LIT:type>": "<STR_LIT:object>",<EOL>"<STR_LIT>": {<EOL>"<STR_LIT:result>": output_schema<EOL>},<EOL>"<STR_LIT>": ["<STR_LIT:result>"]<EOL>}<EOL>)<EOL><DEDENT>except jsonschema.ValidationError as e:<EOL><INDENT>raise TypeError(str(e))<EOL><DEDENT><DEDENT>self.success(output)<EOL><DEDENT>setattr(_wrapper, "<STR_LIT>", input_schema)<EOL>setattr(_wrapper, "<STR_LIT>", output_schema)<EOL>setattr(_wrapper, "<STR_LIT>", input_example)<EOL>setattr(_wrapper, "<STR_LIT>", output_example)<EOL>return _wrapper<EOL><DEDENT>return _validate<EOL>
Parameterized decorator for schema validation

    :type validator_cls: IValidator class
    :type format_checker: jsonschema.FormatChecker or None
    :type on_empty_404: bool
    :param on_empty_404: If this is set, and the result from the
        decorated method is a falsy value, a 404 will be raised.
    :type use_defaults: bool
    :param use_defaults: If this is set, will put 'default' keys
        from schema to self.body (If schema type is object). Example:
            {
                'published': {'type': 'bool', 'default': False}
            }
        self.body will contains 'published' key with value False if no one
        comes from request, also works with nested schemas.