我怎样才能调整这个片段oneOf
到等效的 OpenAPI 2.0 版本?
formats:
type: array
description: Possible parameter format.
items:
oneOf:
- type: string
- type: object
description: Matched alias formats
properties:
representation:
type: array
description: Alias format representations
items:
type: string
match_multiple:
type: boolean
optional: true
display:
type: string
description: Display string of alias format
在 OpenAPI 2.0 中,您最多能做的就是使用无类型模式 https://stackoverflow.com/a/43328994/113116 {}
for items
,这意味着这些项目可以是除null
– 数字、对象、字符串等。您无法指定确切的类型items
,但您可以添加一个example
具有不同项目类型的数组。
formats:
type: array
items: {} # <--- means "any type" (except null)
example:
# example of a string item
- test
# example of an object item
- representation: [one, two]
match_multiple: false
display: something
Note:无类型模式{}
只能用于 OAS2 主体参数和响应模式。路径、标头和表单参数需要原语type
对于数组项。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)