【发布时间】:2018-02-05 14:27:46
【问题描述】:
我想为响应是字典字典的模式建模:
{
'id1': {
'type': 'type1',
'active': true,
},
'id2': {
'type': 'type2',
'active': false,
},
...
...
}
我已经定义了:
components:
schemas:
accountData:
type: object
required:
- type
- active
properties:
type:
type: string
active:
type: boolean
accounts:
type: object
additionalProperties:
type: object
properties:
account-id:
type: object
$ref: '#/components/schemas/accountData'
现在我想定义“#/components/schemas/accounts”,它是“#/components/schemas/account”的重复字典。
我对 OpenApi 3 很陌生,我不知道该怎么做。
【问题讨论】:
-
你试过什么?那怎么行不通?看看这是否有帮助:Swagger HashMap property type、Swagger: map of <string, Object>
-
所以你有一个
<string, Object>地图。在我之前的评论中查看链接问题的答案。这些答案适用于 OpenAPI 2.0,因此请将definitions替换为components.schemas以适应 3.0 语法。 -
@helen 我已经更新了这个问题。你能检查一下我做得对吗?
标签: swagger swagger-editor openapi