我'm trying to define a post endpoint using swagger, but it isn' t允许 requestBody
参数:
/names/{roster}:
get:
#...
post:
x-swagger-router-controller: names
description: Adds or removes name(s)
operationId: manageNames
parameters:
- name: roster
in: path
description: the roster to use
type: string
required: true
requestBody:
content:
'application/json':
schema:
$ref: '#/definitions/ManageNamesRequest'
当我运行 npm start
时,我明白了:
API Errors:
#/paths/~1names~1{roster}/post: Additional properties not allowed: requestBody
1 error and 0 warnings
我的规格出了什么问题?
1 回答
您可能正在混合使用OpenAPI / Swagger 2.0和OpenAPI 3.0语法 . 您的规范似乎是2.0,但
requestBody
关键字是3.0功能 . 在2.0中,请求体被定义为body参数:更多信息:Describing Request Body