这个问题在这里已经有了答案:
How can I define a property type as being a list (list, set, array, collection) of string in my YAML Swagger definition
(2 个回答)
3年前关闭。
我希望发布一个包含可变数量字符串的数组,例如
["string1", "string2", ... "stringN"]
我目前的 OpenAPI 文档是这样定义的:
schema:
type: array
items:
description: networkIds
type: string
这是对 OpenAPi v3 规范进行编码的正确方法,还是有更精确的方法来指示数组中的一个或多个字符串?
最佳答案
缩进不对- type
和 items
必须在同一级别。
如果数组不能为空并且总是至少有 1 项,则可以添加 minItems: 1
作为额外的约束。如果所有项目都必须是唯一的,请添加 uniqueItems: true
.
schema:
type: array
items:
description: networkIds
type: string
minItems: 1
关于arrays - 使用 OpenAPI v3 规范定义一个或多个字符串数组的正确方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47911331/