Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在swagger中指定交替参数?_Swagger_Swagger 2.0 - Fatal编程技术网

如何在swagger中指定交替参数?

如何在swagger中指定交替参数?,swagger,swagger-2.0,Swagger,Swagger 2.0,是否可能(以及如何)指定依赖于另一个给定参数值的其他参数 例子 我有一个调用PUT/accounts//payment\u method,除了path参数之外,它还需要一些参数 一种是定义要设置的付款方式的付款方式类型 现在:如果直接借记的payment\u method\u type为DD,则允许(需要)一些更多的参数,如账户持有人和iban。 如果是别的东西,例如。gPP,需要其他参数 摘自json 我想去掉长参数列表(因为这里还剩下更多的参数),但按照上面的描述对它们进行分组,并记录一些参

是否可能(以及如何)指定依赖于另一个给定参数值的其他参数

例子 我有一个调用
PUT/accounts//payment\u method
,除了path参数之外,它还需要一些参数

一种是定义要设置的付款方式的
付款方式类型

现在:如果直接借记的
payment\u method\u type
DD
,则允许(需要)一些更多的参数,如
账户持有人
iban
。 如果是别的东西,例如。g<代码>PP
,需要其他参数

摘自json 我想去掉长参数列表(因为这里还剩下更多的参数),但按照上面的描述对它们进行分组,并记录一些参数仅对特殊类型是必需的(并且允许的)

有什么方法可以描述这一点吗?


是否有办法定义一组参数,如一个定义中的所有直接借记参数并引用它?备注:这些参数在
支付方法类型
参数旁边给出,而不是在子对象内。

在当前的招摇过市中不可能有条件参数规格

是,参数数组允许使用
$ref
指针

"parameters": {
  "payment_method_type": {
    "name": "type",
    "description": "Payment method type.",
    "in": "query",
    "required": true,
    "type": "string",
    "enum": [
      "DD", "IV", "PP"
    ]
  },
  "payment_method_data_dd_account_holder": {
    "name": "account_holder",
    "description": "Name of account holder",
    "in": "query",
    "required": false, # but true if payment_method_type == DD
    "type": "string"
  },
  "payment_method_data_dd_iban": {
    "name": "iban",
    "description": "IBAN",
    "in": "query",
    "required": false, # but true if payment_method_type == DD
    "type": "string"
  },
  "payment_method_data_pp_some_info": {
    "name": "some_info",
    "description": "Some info needed for PP",
    "in": "query",
    "required": false, # but true if payment_method_type == PP
    "type": "string"
  },
}
"paths": {
  "/accounts/{account_id}/payment_method": {
    "put": {
      "summary": "Update Payment Method",
      "description": "...",
      "parameters": {
        {
          "$ref": "#/parameters/path_psp_account_id"
        },
        {
          "$ref": "#/parameters/payment_method_type"
        },
        {
          "$ref": "#/parameters/payment_method_data_dd_account_holder"
        },
        {
          "$ref": "#/parameters/payment_method_data_dd_iban"
        },
        {
          "$ref": "#/parameters/payment_method_data_pp_some_info"
        },
      }
    }
  }
}