0

I want to make a Model for request where some part of the request structure may change.

As i don't have uniform structure here. How can i define json model for Amazon Api Gateway?

Request:

Here data inside items.{index}.data is changing according to type_id. Also we are not sure about which item with perticular type_id come at which {index}. even the type of items.{index}.data may change.

  {
    "name":"Jon Doe",
    "items": [
      {
        "type_id":2,
        "data": {
          "km": 10,
          "fuel": 20
        }
      },
      {
        "type_id": 5,
        "data": [
          [
            "id":1,
            "value":2
          ],
          .....
        ]
      },{
        "type_id": 3,
        "data": "data goes here"
      },
      ....
    ]
  }

How should i do this?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Bhaskar Dabhi
  • 841
  • 1
  • 11
  • 28

1 Answers1

0

API Gateway uses JSON schema for model definitions. You can use a union datatype to represent your data object. See this question for an example of such a datatype.

Please note that a data model such as this will pose problems for generating SDKs. If you need SDK support for strictly typed languages, you may want to reconsider this data model.

Community
  • 1
  • 1
Bob Kinney
  • 8,870
  • 1
  • 27
  • 35