【发布时间】:2015-07-29 21:35:25
【问题描述】:
我尝试按照官方檐口文档中的描述添加架构验证,并通过 service_name.post(schema=SomeSchemaClass) 之类的装饰器执行此操作,但它不起作用
import colander
class TrackSchema(colander.MappingSchema):
genre = colander.SchemaNode(colander.String(), location="body", type='str')
@track.post(schema=TrackSchema)
def create_track(request):
...
我得到错误
"status": "error", "errors": [{"location": "body", "name": null, "description": "Expecting value: line 1 column 2 (char 1)"}, {"location": "body", "name": "genre", "description": "genre is missing"}]}
我尝试了不同类型的位置参数,例如查询字符串和标题,但我得到了同样的错误。
【问题讨论】:
标签: python pyramid pylons colander cornice