我刚刚开始使用Swagger Editor/OpenAPI3规范,所以到目前为止还不是很好。我已经在本地机器上安装并运行了Swagger Editor v3.15.2。
这是我到目前为止得到的yaml:
openapi: "3.0.0"
info:
version: 1.0.0
title: Test
paths:
/object:
post:
summary: Create an object
operationId: createObject
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/Object"
responses:
'201':
description: Created
components:
schemas:
Object:
required:
- name
- description
properties:
name:
type: string
description:
type: string
它显示了这个错误:
Errors
Resolver error
e is undefined
Structural error at paths./object
should NOT have additional properties
additionalProperty: responses
Jump to line 6
Structural error at paths./object.post
should have required property 'responses'
missingProperty: responses
Jump to line 7
我已经确保我使用两个空格来表示所有的缩进。当我从编辑器中复制yaml并将其放入Notepad++中时,它看起来很好。我还将其粘贴到另一个编辑器中,并注意到它只使用换行符,而不使用回车。我将其更新为同时使用两者,但仍然得到相同的错误。
我已经用同样的问题看过其他问题,但没有一个解决方案对我有效。所以,我不确定我做错了什么。任何指导都是非常感谢的。
发布于 2021-01-28 01:31:50
你有一个小的缩进问题。
添加一个缩进级别到
responses:
'201':
description: Created
这样你就有了:
openapi: "3.0.0"
info:
version: 1.0.0
title: Test
paths:
/object:
post:
summary: Create an object
operationId: createObject
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/Object"
responses:
'201':
description: Created
components:
schemas:
Object:
required:
- name
- description
properties:
name:
type: string
description:
type: string
https://stackoverflow.com/questions/65923580
复制相似问题