首页 > 解决方案 > 如何要求端点的“fask_restplus”两个字段之一

问题描述

我有一个这样的模型:

my_resource_model = api.model(
  RESOURCE_NAME,
  'month_id': rest.fields.String,
  'week_id': rest.fields.String
)

和这样的资源:

class MyResource(Resource):
  @api.expect(my_resource_model):
  def post(self):
    # need to require either week_id *or* month_id is present in request 

如何指定两个字段都不是必需的,但至少必须通过一个?

标签: pythonflaskflask-restplus

解决方案


推荐阅读