如何使用“properties”关键字解释此 OpenAPI 数组定义?

问题描述

考虑这个 OpenAPI 架构:

Units:
  type: array
  properties:
    empty:
      type: boolean
  items:
    $ref: '#/components/schemas/Unit'

Swagger Editor 呈现如下:

result in right schema pane in Swagger Editor

我应该如何解释“空”属性?为什么将其视为有序映射?

通常数组有 items 但没有直接的 properties

解决方法

在此架构中,properties 部分实际上被忽略了。 properties 部分仅对 type: objecttypeless schemas 有效,但不适用于数组。所以这个定义等价于:

Units:
  type: array
  items:
    $ref: '#/components/schemas/Unit'

Swagger Editor 的模型渲染器中的“OrderedMap”文本可视为显示错误。随意在这里打开一个问题:https://github.com/swagger-api/swagger-ui/issues