Преобразование Толчка для вложенных JSON - PullRequest
0 голосов
/ 10 марта 2020

Я пытаюсь написать spe c для моего Input JSON и ожидаю следующий Output JSON, используя преобразование толчка. Я сталкиваюсь с трудностью, чтобы создать jolt spe c для этого ввода JSON. Я использую следующую ссылку, чтобы попробовать это, но я не могу создать спец. c Толчок

https://jolt-demo.appspot.com/#inception

Пожалуйста, помогите мне написать спецификации для ввода JSON.

Заранее спасибо!

Вход JSON:

    {
  "apiVersion": "gateway.solo.io/v1",
  "kind": "RouteTable",
  "metadata": {
    "labels": {
      "proxy": "eag",
      "app": "TestCard",
      "centralId": "200005020"
    },
    "name": "test-rt"
  },
  "spec": {
    "routes": [
      {
        "matchers": [
          {
            "regex": "/acquisition/digital/test",
            "headers": [
              {
                "name": ":method",
                "value": "GET",
                "invertMatch": true
              }
            ]
          }
        ],
        "options": {
          "ratelimit": {
            "rateLimits": [
              {
                "actions": [
                  {
                    "genericKey": {
                      "descriptorValue": "5000pm"
                    }
                  }
                ]
              }
            ]
          }
        },
        "directResponseAction": {
          "status": 405,
          "body": "{\"Error\" : \"RaiseFault\", \"ErrorCode\" : \"405\", \"ErrorDesc\" : \"Method Not Allowed\" }"
        }
      },
      {
        "matchers": [
          {
            "methods": [
              "GET"
            ],
            "regex": "/acquisition/digital/test",
            "headers": [
              {
                "name": "Authorization",
                "invertMatch": true
              }
            ]
          }
        ],
        "options": {
          "ratelimit": {
            "rateLimits": [
              {
                "actions": [
                  {
                    "genericKey": {
                      "descriptorValue": "5000pm"
                    }
                  }
                ]
              }
            ]
          }
        },
        "directResponseAction": {
          "status": 400,
          "body": "{\"Error\" : \"RaiseFault\", \"ErrorCode\" : \"400\", \"ErrorDesc\" : \"Missing Authorization Header\"}"
        }
      },
      {
        "matchers": [
          {
            "methods": [
              "GET"
            ],
            "regex": "/acquisition/digital/test"
          }
        ],
        "options": {
          "extauth": {
            "configRef": {
              "name": "hmac-auth"
            }
          },
          "ratelimit": {
            "rateLimits": [
              {
                "actions": [
                  {
                    "genericKey": {
                      "descriptorValue": "5000pm"
                    }
                  }
                ]
              }
            ]
          }
        }
      }
    ]
  }
}

Ожидаемый вывод JSON

{
  "apigeeVSeag": "true",
  "proxyName": "TestCard",
  "env": "e1",
  "EndPoint": [
    {
      "path": "/acquisition/digital/test",
      "Policies": [
        {
          "PolicyName": "MatchingHeader",
          "Attributes": [
            {
              "CustomError": "{'Error' : 'RaiseFault', 'ErrorCode' : '405', 'ErrorDesc' : 'Method Not Allowed' }",
              "name": ":method",
              "invertmatch": "true",
              "value": "GET",
              "status": 405
            }
          ]
        },
        {
          "PolicyName": "Ratelimit",
          "Attributes": [
            {
              "value": "5000pm"
            }
          ]
        },
        {
          "PolicyName": "CheckMissingHeaders",
          "Attributes": [
            {
              "CustomError": "{'Error' : 'RaiseFault', 'ErrorCode' : '400', 'ErrorDesc' : 'Missing Authorization Header'}",
              "name": "Authorization",
              "invertmatch": "true",
              "status": 400
            }
          ]
        },
        {
          "PolicyName": "ExtAuth",
          "Attributes": [
            {
              "name": "hmac-auth"
            }
          ]
        }
      ]
    }
  ]
}
...