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
评论列表
文章目录