如何在swagger中描述数据类型数组[]的参数

时间:2018-03-12 21:20:17

标签: swagger swagger-ui

如何将数组对象传递给swagger UI中的参数?这是一个GET请求。 我有一个数据类型的请求参数:Array []和参数类型:查询。 我试过下面的数组,它似乎没有工作。我不熟悉Swagger的用法。无法弄清楚问题。

["dataType": 1,"value": "test","orderid": 1]
[1,1 , 1, 1]
[{1,1 , 1, 1}]
[{"dataType": 1,"value": "test","orderid": 1}]
[ dataType: 1]

型号:

public class ItemModel
{
    public int DataType { get; set; }
    public string Value { get; set; }
    public int OrderId { get; set; }
}

1 个答案:

答案 0 :(得分:0)

您要在此处执行的操作是在components部分(schema子部分)中包含对象定义,然后使用$ref关键字链接到{{1}下的模式}。

以下是我使用您描述的参数进行处理的快速示例:

示例:

架构:

items:

定义:

components:
  schemas:
    itemModel:
      properties:
        dataType:
          type: integer
        value:
          type: string
        orderType:
          type: integer
    requestParam:
      properties:
        orders:
          type: array
          items:
            $ref: '#/components/schemas/requestParam'

另一个例子(子弹点3) http://blog.restcase.com/6-most-significant-changes-in-oas-3-0/

相关问题