validation.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:ramlwrap 作者: jmons 项目源码 文件源码
def _example_api(request, schema, example):

    response = None
    if schema:
        # If there is a problem with the json data, return a 400.
        try:
            data = json.loads(request.body.decode("utf-8"))
            validate(data, schema)
        except Exception as e:
            if hasattr(settings, 'RAMLWRAP_VALIDATION_ERROR_HANDLER') and settings.RAMLWRAP_VALIDATION_ERROR_HANDLER:
                response = _call_custom_handler(e)
            else:
                response = _validation_error_handler(e)

    if response:
        return response

    if not example:
        return None
    else:
        return example
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号