0

I want my OpenAPI spec to display the list of both the objects like below but I'm unable to do so.

[
  {
    "studentID": 1,
    "studentName": "Ram"
  },
  {
    "studentID": 2,
    "studentName": "Shyam"
  }
]

Swagger Spec in editor.swagger.io:

enter image description here

Helen
  • 87,344
  • 17
  • 243
  • 314
Puneet
  • 13
  • 1
  • 6
  • Also: [How to return an array of objects in SwaggerHub?](https://stackoverflow.com/a/46192564/113116) – Helen Jun 04 '21 at 08:21

1 Answers1

0

example keyword should be at the same level of items:

200:
  description: success response
  content:
    application/json:
      schema:
        type: array
        items:
          properties:
            studentID:
              type: integer
            studentName:
              type: string
        example:
          - { "studentID": 1, "studentName": "Ram" }
          - { "studentID": 2, "studentName": "Shyam" }
Héctor
  • 24,444
  • 35
  • 132
  • 243