Swagger 编辑器在指定响应时抛出错误 "Not a valid response definition"
Swagger editor is throwing error while specifying the response "Not a valid response definition"
我正在尝试使用 swagger editor 生成 API 文档。我将我的 API 规格指定如下
paths:
/opendata/v1/{index}:
get:
tags: [verification]
description: Verify the person information
parameters:
- name: index
in: path
description: specific data index
required: true
type: string
- name: name
in: query
description: name of a person
required: false
type: string
- name: company name
in: query
description: name of a company
required: false
type: string
responses:
'200':
description: Success
content:
application/json:
schemas:
$ref: '#/responses/200'
responses:
'200':
description: Success
schema:
type: object
properties:
verification:
type: string
但是"Not a valid response definition"在编辑器中总是显示错误。我检查了 here 的响应规范。我应该做些什么改变才不会出现错误。
注意:我想要 json 形式的回复,如下所示:
{
verification:string
}
您正在混合使用 OpenAPI/Swagger 2.0 和 OpenAPI 3.0 语法。您的规范似乎是 swagger: '2.0'
,因此您应该使用:
paths:
/opendata/v1/{index}:
get:
...
produces:
- application/json
responses:
200:
$ref: '#/responses/200'
这是相关的 OpenAPI/Swagger 2.0 指南:Describing Responses
我正在尝试使用 swagger editor 生成 API 文档。我将我的 API 规格指定如下
paths:
/opendata/v1/{index}:
get:
tags: [verification]
description: Verify the person information
parameters:
- name: index
in: path
description: specific data index
required: true
type: string
- name: name
in: query
description: name of a person
required: false
type: string
- name: company name
in: query
description: name of a company
required: false
type: string
responses:
'200':
description: Success
content:
application/json:
schemas:
$ref: '#/responses/200'
responses:
'200':
description: Success
schema:
type: object
properties:
verification:
type: string
但是"Not a valid response definition"在编辑器中总是显示错误。我检查了 here 的响应规范。我应该做些什么改变才不会出现错误。
注意:我想要 json 形式的回复,如下所示:
{
verification:string
}
您正在混合使用 OpenAPI/Swagger 2.0 和 OpenAPI 3.0 语法。您的规范似乎是 swagger: '2.0'
,因此您应该使用:
paths:
/opendata/v1/{index}:
get:
...
produces:
- application/json
responses:
200:
$ref: '#/responses/200'
这是相关的 OpenAPI/Swagger 2.0 指南:Describing Responses