0

I'm writing an API doc, and I have an endpoint returning multiple items of the same thing. I would like to have more items in the response example, but coming from different refs

here is the endpoint response documentation:

      responses:
        '200':
          description: json containing the updated notification
          content:
            application/json:
              schema:
                type: object
                properties:
                  payload:
                    type: array
                    items:
                      $ref: "#/components/schemas/forecast_item"

here's the item schema:

    forecast_item:
      type: object
      properties:
        transmission_date:
          type: string
        timestamp:
          type: number
        temperature:
          type: number
        humidity:
          type: number
        rain:
          type: number
        icon:
          type: string
      example:
        transmission_date: "2022-06-08 12:00:00"
        timestamp: 1654689600
        temperature: 28.28
        humidity: 33
        rain: 0
        icon: 04d

the above produce the following example:

{
  "payload": [
    {
      "transmission_date": "2022-06-08 12:00:00",
      "timestamp": 1654689600,
      "temperature": 28.28,
      "humidity": 33,
      "rain": 0,
      "icon": "04d"
    }
  ]
}

How do I achieve the following:

{
  "payload": [
    {
      "transmission_date": "2022-06-08 12:00:00",
      "timestamp": 1654689600,
      "temperature": 28.28,
      "humidity": 33,
      "rain": 0,
      "icon": "04d"
    },
{
      "transmission_date": "2022-06-08 12:00:00",
      "timestamp": 1654689600,
      "temperature": 28.28,
      "humidity": 33,
      "rain": 0,
      "icon": "04d"
    },
{
      "transmission_date": "2022-06-08 12:00:00",
      "timestamp": 1654689600,
      "temperature": 28.28,
      "humidity": 33,
      "rain": 0,
      "icon": "04d"
    }
  ]
}
2
  • A multi-item example can be specified on the array level - see the linked Q&A, specifically the 2nd example in the accepted answer. Commented Jun 14, 2022 at 19:46
  • yes, but that doesn't work when using refs, what do i do if i have multiple refs ? Commented Jun 14, 2022 at 19:58

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.