Forum Discussion

Sibqo's avatar
Occasional Contributor
3 years ago

schema of the responses when response parameters are repeated itself

Hi! i want to ask about the responses like: If the api returns the list of all the users then in the response there is a list of users and each user having the same parameters like this: [ { "id...
  • HKosova's avatar
    3 years ago

    If you mean array examples with multiple items, that's supported in OpenAPI 2.0 too. The "example" keyword needs to be alongside "type: array", like so:

              description: A list of users
                type: array
                  $ref: '#/definitions/User'
                example:   # <--- on the same level as "type: array"
                  - id: 1
                    code: 2y1
                  - id: 2
                    code: 2y1


    If you mean multiple different examples for the same response or parameter, that's only supported in OpenAPI 3.0.