我正在尝试使用swagger编辑器创建我的API定义。 我已经看过swagger规范和宠物商店示例,但是当我创建一个端点时,我一直收到这个错误:
Schema error at paths./crash/{crashId}/.post.parameters[0]
is not exactly one from <#/definitions/parameter>,
<#/definitions/jsonReference>
Schema error at paths./crash/{crashId}/.post.parameters[1]
is not exactly one from <#/definitions/parameter>,
<#/definitions/jsonReference>
这是错误起源的yaml:
/crash/{crashId}/:
post:
tags:
- crash
summary: Adds a feedback report
description: Can add a feedback report with or without a crash
consumes:
- application/json
produces:
- application/json
parameters:
- name: crashId
in: path
description: the crash id parameter that this feedback report should
connect to
required: false
type: integer
format: int32
- name: feedbackreport
in: body
description: the feedbackreport
require: true
schema:
$ref: '#/definitions/NewFeedbackReport'
responses:
'200':
description: OK
预览仍然可以正常工作,当我把它放在我的招摇UI中时,它看起来就像我想要的那样。
有什么问题?我可以忽略这个吗?
答案 0 :(得分:1)
1)路径参数(in: path
)必须为required: true
,因为它们始终是必需的。
2)在body参数中,将require
更改为required
。