如何记录预期发布的输入正文value
字段出现以便用户知道要发布什么?目前使用以下数据:
{
"customer_id": "",
"service_id": "",
"customer_name": "",
"site_name": "",
"service_type": ""
}
我们可以使用上面的 json 来默认填充该值吗?
Code:
post_parser = reqparse.RequestParser()
post_parser.add_argument('database', type=list, help='user data', location='json')
@ns_database.route('/insert_user')
class database(Resource):
@ns_database.expect(post_parser)
def post(self):
"""insert data"""
json_data = request.json
customer_id = json_data['customer_id']
service_id = json_data['service_id']
customer_name = json_data['customer_name']
site_name = json_data['site_name']
service_type = json_data['service_type']
我已经使用以下模型(部分)解决了它
""" Model for documenting the API"""
insert_user_data = ns_database.model(
"Insert_user_data",
{
"customer_id": fields.String(description="cust ID", required=True),
"service_id": fields.String(description="service ID", required=True),
"customer_name": fields.String(description="Customer1", required=True),
"site_name": fields.String(description="site", required=True),
"service_type": fields.String(description="service", required=True),
},
)
@ns_database.route("/insert_user")
class database(Resource):
@ns_database.expect(insert_user_data)
def post(self):
"""insert data"""
json_data = request.json
customer_id = json_data["customer_id"]
service_id = json_data["service_id"]
customer_name = json_data["customer_name"]
site_name = json_data["site_name"]
service_type = json_data["service_type"]
现在 API 显示了数据输入模型和示例
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)