1
我正在編寫一個API的Swagger文檔,並且一個端點返回許多嵌套的對象和參數。Swagger UI:數組中的多個匿名對象
但有一個返回的數組不返回常規參數。相反,它會返回兩個匿名對象來保存這些參數。
"balanceDisplaySettings": [
{
"type": "Balance",
"label": "Current",
"visible": true,
"primary": false
},
{
"type": "AvailableBalance",
"label": "Available",
"visible": true,
"primary": true
}
]
YAML
swagger: '2.0'
schemes:
- https
consumes:
- application/json
produces:
- application/json
paths:
"/Path/":
responses:
'200':
description: OK
schema:
type: object
properties:
balanceDisplaySettings:
type: array
items:
type: object
properties:
type:
type: "Balance"
description: description
label:
type: "Available"
description: description
visible:
type: boolean
description: description
primary:
type: boolean
description: description
type: object
properties:
type:
type: "AvailableBalance"
description: description
label:
type: "Available"
description: description
visible:
type: boolean
description: description
primary:
type: boolean
description: description
看着昂首闊步的描述請求機構的文件,也似乎沒有辦法處理的對象沒有名字。
我如何(使用YAML)在Swagger-UI中記錄這種類型的響應正文?
我得到錯誤「重複的映射鍵」在網上揚鞭編輯器添加多個對象數組 – Arlo
@ChuckFecht的時候,你可以發佈你正在使用的YAML代碼? (例如更新這個問題或發佈一個新問題) – Helen
更新了問題 – Arlo