2

I have completed a Node.js app using LINE APIs.I have the following request object. How can I define the array of different objects, here the messagesfield which contains different object structure for different message types. I hope swagger permits this very common scenario.

Request Body:

    {
            "to": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "messages":[
                {
                    "type":"text",
                    "text":"Hello, world1"
                },
                {
                     "type": "audio",
                     "originalContentUrl": "https://example.com/original.m4a",
                     "duration": 240000
                }
                {
                     "type": "location",
                     "title": "my location",
                     "address": "〒150-0002 東京都渋谷区渋谷2丁目21−1",
                     "latitude": 35.65910807942215,
                     "longitude": 139.70372892916203
                }
            ]
        }

My swagger definition for messages array.

"Messages Object": {
      "type": "array",
      "items": {
        "allOf": [
          {
            "$ref": "#/definitions/multicast Message Error Response"
          },
          {
            "$ref": "#/definitions/multicast Message Error Response"
          }
        ]
      }
    }

And this is the rendered messages array. It has only one entry. I want to include many different entries

"messages": [
    {
      "code": 500,
      "httpCode": 400,
      "name": "string",
      "message": "string"
    }
  ]
Nidhin David
  • 2,426
  • 3
  • 31
  • 45
  • 1
    Possible duplicate of [How do you create a swagger schema that includes an array of varying types](https://stackoverflow.com/questions/36318849/how-do-you-create-a-swagger-schema-that-includes-an-array-of-varying-types) – Helen Jun 28 '17 at 13:20

0 Answers0