我使用烧瓶、flasgger ( yml文件定义的swagger)和webargs创建了python:
@app.route('/api/set/', methods=['PUT'])
@swag_from('swagger/put_community_sets.yml')
@use_kwargs({'community_set': fields.List(fields.Str(),
location='json', required=True)})
def put_community_set(community_set):
print 'community_set to add: ' + str(community_set)put_community_sets.yml:
tags:
- put community set API
parameters:
- name: body
in: body
schema:
id: put_community_set
required:
- community_set
properties:
community_set:
type: array
items:
type: string
description: the community set to be added
responses:
'200':
description: added a new community set作为一个测试,我运行我的烧瓶应用程序并发送一个HTTP
header = Content-Type,application/json
body = "test1“、"test2”、"test3“
我得到: 422个不可处理实体,请求格式良好,但由于语义错误无法遵循。
我猜想yml文件中的swagger定义、@use_kwargs参数或我的测试输出可能有问题。
发布于 2017-10-22 05:10:41
所以我自己想出来了。
必须使用:{"community_set":"test1“、"test2”、"test3"}
不仅仅是:"test1“、"test2”、"test3“
https://stackoverflow.com/questions/46858123
复制相似问题