【问题标题】:While creating the REST API documentation using Swagger 2.0 getting this error使用 Swagger 2.0 创建 REST API 文档时出现此错误
【发布时间】:2017-05-31 13:59:10
【问题描述】:

为什么我在 Swagger 编辑器中收到“操作不能有多个主体参数”错误?

【问题讨论】:

  • 您的一个 api 方法中有多个主体参数,这是不允许的。

标签: swagger swagger-2.0 swagger-editor


【解决方案1】:

错误正是它所说的,“操作不能有多个主体参数”。在您的示例中,错误出现在 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'

【讨论】:

    猜你喜欢
    • 2017-04-09
    • 1970-01-01
    • 1970-01-01
    • 2019-11-25
    • 1970-01-01
    • 1970-01-01
    • 2021-12-23
    • 1970-01-01
    • 2015-04-25
    相关资源
    最近更新 更多