【问题标题】:Swagger error when trying to import JSON尝试导入 JSON 时出现 Swagger 错误
【发布时间】:2016-04-22 15:06:00
【问题描述】:

我已经使用查询参数成功定义了一个 API,但想通过 JSON 对象传递所有状态。

我定义了以下 YAML 文件:

paths:
  /contact-us:
    post:
      summary: Contact Us
      description: |
        Originates a new conversation thread 
      consumes:
        - application/json
      parameters:
        - in: body
          required: true
          schema:
            $ref: '#/definitions/RequestConversation'
      tags:
        - Email
      responses:
        200:
          description: New conversation has been originated
          schema:
            $ref: '#/definitions/Conversation'

这会导致parameters 行出错,该行指出:

数据与“oneOf”中的任何模式都不匹配

但我在同一个 YAML 文件中确实有以下定义:

definitions:
  RequestConversation:
    type: object
    properties:
      company_id:
        type: string
        # required: true
      user_email:
        type: string
        # required: true
      type:
        type: string
        # required: true
        default: 'contact-us'
      sub_type:
        type: string
      campaign:
        type: string

另请注意,“必需”定义已被注释掉,这是因为它们给了我一个不同的错误:

预期类型数组,但找到类型布尔

有人可以帮忙吗?

【问题讨论】:

    标签: swagger swagger-2.0


    【解决方案1】:

    好的解决了我自己的问题(至少第一部分)。希望这将使其他人受益:

    1. 第一个问题实际上只是我没有指定必需的“名称”属性。

    2. 这仍然是打开的(又名,它可以工作,但不能使用“必需”属性)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-14
      相关资源
      最近更新 更多