0

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

在此处输入图像描述

我的定义与文档中的示例相匹配,所以我不确定是什么导致了问题。

片段

/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
4

1 回答 1

0

您的文档中有几个错误:

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