使用OpenAPI v3规范定义一个或多个字符串数组的正确方法[重复]

问题描述 投票:2回答:1

我希望POST一个包含可变数量字符串的数组,例如

[“string1”,“string2”,...“string”]

我目前的OpenAPI文档以这种方式定义它:

schema:
  type: array
    items:
      description: networkIds
      type: string

这是编码OpenAPi v3规范的正确方法,还是有更精确的方法来指示数组中的一个或多个字符串?

arrays swagger openapi
1个回答
3
投票

缩进是错误的 - typeitems必须处于同一水平。

如果数组不能为空并且始终至少有1个项,则可以添加minItems: 1作为附加约束。如果所有项目都必须是唯一的,请添加uniqueItems: true

schema:
  type: array
  items:
    description: networkIds
    type: string
  minItems: 1
© www.soinside.com 2019 - 2024. All rights reserved.