Flask JSON验证WTForms

2024-10-03 00:30:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用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}$

你知道我做错什么了吗?在


Tags: fromimportflaskobjectschemadeftyperesource