如何在Swagger 2.0中引用顶级参数

时间:2014-11-06 21:29:57

标签: swagger swagger-ui

我正在试图弄清楚如何使用顶级参数,然后在操作级别使用$ ref来引用在顶级对象中声明的定义。

以下是YAML的样子,但是当我尝试这个时,我会显示一个空参数。有人知道这个的正确语法吗?

swagger: '2.0'
info:
  version: 0.1.0
  title: Customer API
parameters:
  index:
    name: index
    in: query
    description: Specifies the offset of the first item to be returned. The default value is 0, which starts at the beginning.
    type: integer
    default: 0
    minimum: 0
paths:
  /customers:
    get:
      parameters:
        - $ref: '#/parameters/index'
      responses:
        200:
          description:  List all customers
          schema:
            $ref: '#/definitions/Customers'
definitions:
  Customer:
    properties:
      name:
        type: string
      id:
        type: integer
        format: int32
  Customers:
    properties:
      startIndex:
        type: integer
      itemsPerPage:
        type: integer
      totalResults:
        type: integer
      entries:
        type: array
        $ref: Customer

1 个答案:

答案 0 :(得分:0)

对此的支持尚未在swagger-ui中实施。请参阅https://github.com/swagger-api/swagger-ui/issues/621