【发布时间】:2018-08-11 18:23:16
【问题描述】:
到目前为止,我有以下内容:
Links:
description: Must contain links objects
type: object
properties:
$ref: "#/components/schemas/Link"
ErrorLinks:
allOf:
- $ref: "#/components/schemas/Links"
- properties:
about:
$ref: "#/components/schemas/Link"
在Links 中,我不在乎任何properties 的名称是什么,只是它们都是Link 对象。在ErrorLinks 中,我希望有一个about 属性,它也是一个Link 对象。
这是定义它的正确方法,还是我说(在 Links 中)我希望 properties 节点本身是 Link 对象?
我发现 openapi 文档有点缺乏有用的示例,以上验证过,所以我不完全确定。
【问题讨论】:
-
这些问题在Swagger: map of <string, Object> 和Property reference to Model on swagger 2.0 (nesting) 中也得到了解答,只需将
#/definitions/(OpenAPI/Swagger 2.0 语法)替换为#/components/schemas/(OpenAPI 3.0 语法)即可。
标签: openapi