招摇编辑器中的错误"bad indentation of a mapping entry"



在下面的OpenAPI定义中,参数定义导致解析器错误"bad indentation of a mapping entry"。怎么了?"属性"出错(最后5行)

responses:
'200':
description: OK
content:
application/json;charset=UTF-8:
schema:
type: object
properties:
creationTime:
type: string
format: date-time
description: >-
The date and time the response was created in GMT time
with a format of "MM-dd-yyyy HH:mm:ss.SSSZ"
example: '03-12-2019 14:05:35.182-0500'
response:
type: array
description: ''
properties:
recordID:
type: string
maxLength: 20
externalID:

由于properties关键字比其兄弟typedescription关键字缩进更多而出现错误。

response:
type: array
description: ''
properties:     # <---- Indentation doesn't match the sibling
#       `type` and `description` keywords

但是,type: array模式需要items,而不是properties

看起来response键要么缺少一些关键字,要么有额外的关键字。response的正确定义应该是:
response:
type: object      # <----------
description: ''
properties:       # <----------
recordID:
type: string
maxLength: 20
externalID:
...

response:
type: array
description: ''
items:             # <----------
type: object     # <----------
properties:      # <----------
recordID:
type: string
maxLength: 20
externalID:
...

取决于你需要什么

最新更新