使用 Swagger 2.0 创建 REST API 文档时出现此错误
While creating the REST API documentation using Swagger 2.0 getting this error
为什么我在 Swagger 编辑器中收到 "operation cannot have multiple body parameters" 错误?
错误如其所言,"operation cannot have multiple body parameters"。在您的示例中,错误出在 POST /company/fastbill/customers
操作中。
一个body
参数表示请求体。所以如果你想 POST 多个数据对象,你需要将它们组合成一个单一的对象负载。例如:
- name: body
in: body
required: true
schema:
type: object
properties:
customer_details:
$ref: '#/definitions/Customer'
bank_account:
type: object
properties:
sources:
type: array
items:
$ref: '#/definitions/BankAccount'
为什么我在 Swagger 编辑器中收到 "operation cannot have multiple body parameters" 错误?
错误如其所言,"operation cannot have multiple body parameters"。在您的示例中,错误出在 POST /company/fastbill/customers
操作中。
一个body
参数表示请求体。所以如果你想 POST 多个数据对象,你需要将它们组合成一个单一的对象负载。例如:
- name: body
in: body
required: true
schema:
type: object
properties:
customer_details:
$ref: '#/definitions/Customer'
bank_account:
type: object
properties:
sources:
type: array
items:
$ref: '#/definitions/BankAccount'