繁体   English   中英

尝试导入JSON时出现大幅错误

[英]Swagger error when trying to import JSON

我已经成功使用查询参数定义了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

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

预期的类型数组,但发现类型为布尔值

有人可以帮忙吗?

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM