我正在尝试使用JSONSchema验证为restfulapi启用flask_输入。 代码如下:
from flask_inputs import Inputs
from flask_inputs.validators import JsonSchema
def GetValidSchema():
schema = {
'type': 'object',
'properties': {
'name': {'type': 'string'}
}
}
return schema
class ApiResource(resource)
class ApiInputs(Inputs):
schema = InputsValidation.GetValidSchema() # this returns the JSON schema object
json = [JsonSchema(schema=schema)]
def post(self):
inputs =self.ApiInputs(request)
print inputs.validate()
api.add_resource(ApiResource,'/test')
我真的需要一些帮助,因为我试图找出WT表格,但不幸的是,我无法清楚地得出我为什么会出现以下错误:
^{pr2}$你知道我做错什么了吗?在
您正在用验证器以外的东西污染
ApiInputs
命名空间。试试这个:示例程序:
^{pr2}$相关问题 更多 >
编程相关推荐