How to add multiple example values in swagger properties?

Solution 1:

To display an array example with multiple items, add the example on the array level instead of item level:

cities:
  type: array
  items:
    type: string
  example:
    - Pune
    - Mumbai
    - Bangaluru

  # or
  # example: [Pune, Mumbai, Bangaluru]

In case of array of objects, the example would look like this:

type: array
items:
  type: object
  properties:
    id:
      type: integer
    name:
      type: string
example:
  - id: 1
    name: Prashant
  - id: 2
    name: Helen