我在swagger.io上记录了一个API。当我尝试将session_token定义为标头中的必需字符串属性时,我收到错误:
我的定义与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
答案 0 :(得分:0)
文档中的一些错误:
VerificationCode
显示type: string
和schema:
。对于正文参数(in: body
),您只能使用schema
。只需删除type: string
。code
的定义有一些不需要的字段:
in: body
。这可能是复制/粘贴错误required: true
。这不是说出属性的正确方法,将其移动到properties
对象的兄弟节点,如下所示:required: - code properties: code: # the rest of your definition