Swagger定义占位符?

时间:2019-02-03 22:08:26

标签: swagger

我正在创建一个规范的说明,并且停留在定义部分,主要用于表示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。

0 个答案:

没有答案