0

How do I pass an array object to a parameter in swagger UI? This is a GET request. I have a request parameter of Data Type: Array[] and Parameter Type: query. I have tried with below arrays and it doesnt seem to work. I am not familiar with Swagger usage. Unable to figure out the issue.

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

Model:

public class ItemModel
{
    public int DataType { get; set; }
    public string Value { get; set; }
    public int OrderId { get; set; }
}
Kar
  • 105
  • 11

1 Answers1

0

What you want to do here is include the object definition in the components section (schema subsection) and then use the $ref keyword to link to the schema under items:.

Here is quick example I worked up using the parameters you describe:

example:

Schema:

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

Definition:

    paths:
  /pets:
    post:
      summary: Add a new pet

      requestBody:
        description: Optional description in *Markdown*
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/requestParam'

Another example (bullet point 3) http://blog.restcase.com/6-most-significant-changes-in-oas-3-0/

Taylor Ackley
  • 1,397
  • 1
  • 16
  • 31