Forum Discussion

mariusBV's avatar
mariusBV
New Contributor
5 years ago

Validation with Spectral fails `example` property type should be array

Hello all,

 

bellow it's my OpenAPI specification that is failing when validation with Spectral because "`example` property type should be array".
I don't understand what is wrong with my example specification for an array of query parameters.

    put:
      callbacks: {}
      deprecated: false
      description: inviteUsers
      operationId: UserController.bulk_invite
      parameters:
        - description: list of User IDs to invite
          example: '?ids[]=58a45e20-6878-4e8f-9d7b-44622bc49bb2&ids[]=58a45e20-6878-4e8f-9d7b-44622bc49bb2'
          explode: true
          in: query
          name: 'ids[]'
          schema:
            items:
              description: id
              type: string
            type: array
          style: form

 Regards,

  • Replace

    example: '?ids[]=58a45e20-6878-4e8f-9d7b-44622bc49bb2&ids[]=58a45e20-6878-4e8f-9d7b-44622bc49bb2'

    with

    example:
      - 58a45e20-6878-4e8f-9d7b-44622bc49bb2
      - 58a45e20-6878-4e8f-9d7b-44622bc49bb2

     

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Replace

    example: '?ids[]=58a45e20-6878-4e8f-9d7b-44622bc49bb2&ids[]=58a45e20-6878-4e8f-9d7b-44622bc49bb2'

    with

    example:
      - 58a45e20-6878-4e8f-9d7b-44622bc49bb2
      - 58a45e20-6878-4e8f-9d7b-44622bc49bb2