在 CUE 中定义数组并导出到 OpenAPI

问题描述

对于以下简单的 CUE 代码,它定义了一个 match 对象,该对象包含两个团队名称(作为两个字符串的数组)和比赛得分(作为两个整数的数组):

#match: {
    id: int
    teams: 2 * [string]
    score: 2 * [int]
}

当我运行 cue export --out openapi test.cue(使用 CUE v0.4.0)时,我收到错误消息:

components.schemas.match.properties.score.default.0: incomplete value int
components.schemas.match.properties.score.default.1: incomplete value int
components.schemas.match.properties.teams.default.0: incomplete value string
components.schemas.match.properties.teams.default.1: incomplete value string

如果我将 string 更改为 string | *null,它会起作用 - 但是我真的不明白为什么数组的元素需要具有认值才能作为 OpenAPI 导出(尤其是因为对对象属性没有这样的要求)?我在这里遗漏了什么吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)