这种模式在我的项目中反复出现(六次):
type: object
properties:
total:
type: integer
description: the count of all items that match the query
hits:
type: array
description: a single page of results
items:
$ref: '#/definitions/{various schema}'
这种重复图案的内部 ( {various schema}
) 因每次使用而异。我想为其中的每一个引用共享代码,而不是重复自己。我通常会使用$ref
,但由于变量位,这似乎在这里不起作用。
我试图anyOf
为我工作,但它只有助于改变properties
a object
,但我试图改变items
a array
。
有什么我想念的吗?可能是一个小的重构以使其适合可重用的模式?