我正在创建一个规范的说明,并且停留在定义部分,主要用于表示PagedResult定义,请参见下文:
definitions:
PagedResult:
type: "object"
properties:
count:
type: "integer"
next:
type: "string"
previous:
type: "string"
results:
type: array
items: <placeholder>?
Device:
type: "object"
properties:
type:
type: "string"
id:
type: "string"
PagedResult定义的results
项对任何定义都是通用的,如何在API响应中指定它以将特定类型注入results
项中?例如
paths:
/machines:
get:
operationId: "getMachines"
consumes:
- "application/json"
parameters:
- name: "customer"
in: "query"
description: "Get machines by customer"
required: false
type: "string"
responses:
200:
description: "successful operation"
schema:
type: "array"
items:
$ref: "#/definitions/PagedResult" <----- how to inject Device definition here?
我读到有关重用定义的信息,但似乎情况恰恰相反。而且我真的不想为每个定义都复制粘贴PagedResult。