swagger.io:标题必需属性

时间:2016-05-09 12:42:32

标签: swagger swagger-editor

我在swagger.io上记录了一个API。当我尝试将session_token定义为标头中的必需字符串属性时,我收到错误:

enter image description here

我的定义与documentation中的样本匹配,所以我不确定是什么 导致问题。

/customerVerifyLogin:
    post:
      summary: Validate verification code sent to authenticate login. Returns session_token
      parameters:
        - name: Authorization
          in: header
          type: string
          required: true
          default: Basic YWRtaW46WDRCbzViWnZTamlXU0hoZDFMOGNpUHkyUERzekUwU3I=
        - name: session_type
          in: header
          type: string
          enum: 
            - android
            - ios
          required: true
        - name: VerificationCode
          in: body
          type: string
          required: true
          description:
          schema:
            type: object
            properties:
              phone:
                type: string
                description: The mobile number to which the verification was sent.
              device_id:
                type: string
                description: ID that uniquely identifies the device
              code:
                in: body
                type: integer
                format: int32
                required: true
                description: Verification code to be validated.
      responses:
        200:
          description: Customer logged-in successfully.
          schema:
            $ref: '#/definitions/Customer'
      tags:
        - Verification
        - Login

1 个答案:

答案 0 :(得分:0)

文档中的一些错误:

  • VerificationCode显示type: stringschema:。对于正文参数(in: body),您只能使用schema。只需删除type: string
  • 即可
  • 您对属性code的定义有一些不需要的字段:
    • 删除in: body。这可能是复制/粘贴错误
    • 删除required: true。这不是说出属性的正确方法,将其移动到properties对象的兄弟节点,如下所示:
required:
  - code
properties:
  code:
   # the rest of your definition