我在 swagger yaml 中定义对象数组时遇到问题。每次我尝试定义 yaml 的 type: array 部分时,Swagger 编辑器都会给出错误。我定义了它,但它不正确,因为它给出了错误。
以下是我尝试在 swagger yaml 中定义的 json。
{
"CountryCombo": {
"options": {
"option": [{
"id": "GB",
"value": "GB Great Britain"
}, {
"id": "US",
"value": "US United States"
}, {
"id": "AD",
"value": "AD Andorra, Principality of"
}]
}
}
}
我将此 json 定义为 swagger yaml ,如下所示,但它给出了错误:
CountryCombo:
type: object
properties:
options:
type: object
properties:
option:
type: array
items:
- id:
type: string
description: GB
value:
type: string
description: GB Great Britain
- id:
type: string
description: US
value:
type: string
description: US United States
- id:
type: string
description: AD
value:
type: string
description: AD Andorra, Principality of
谁能建议我如何按照 swagger 规范在 yaml 中定义这个 json?
在架构中,您不需要值,只需要值的描述。
CountryCombo:
type: object
properties:
options:
type: object
properties:
option:
type: array
items:
type: object
properties:
id:
type: string
value:
type: string
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)