首页 > 解决方案 > AWS 网关 - 由于负载(“方法执行”)与所需资源模型结果之间未对齐而导致的 500 错误

问题描述

我们正在为我们的 AWS Gateway API 构建最终资源树,该资源树由 4 个不同的 JSON 模型组成,每个模型都是前一个模型的子集。这里的目标是将它们全部整合到一个 JSON 有效负载中并成功执行它们。

问题是知道最终的 JSON 会是什么样子——我们很接近,但并不完全确定。当我们通过“方法执行”去执行时,我们得到一个 500(对于失败的转换)。因此,再次强调,目标是了解最终的 JSON 转换应该是什么样子。

第一个对象:

  "type" : "object",
  "properties" : {
    "identifier" : {
      "type" : "string",
      "description" : "unique Identifier"
    },
    "templateData" : {
      "$ref":"~path~/models/beneObjectTemplateData"
    }
}
}

第二个对象是“beneObjectTemplateData”的子集:

  "properties" : {
    "beneData" : {
      "$ref":"~path~/models/beneData"
    }
  },
  "description" : "Beneficiary specific data"
}

第三个对象是“beneData”的一个子集:

  "type" : "object",
  "properties" : {
    "beneSpecific" : {
      "$ref":"~path~/models/beneSpecific"
    }
  },
  "description" : "Beneficiary data"
}

最后一个对象是“beneSpecific”的子集:

{
  "type" : "object",
  "properties" : {
    "name" : {
      "type" : "string"
    },
    "classification" : {
      "type" : "string",
      "description" : "Type of beneficiary",
      "pattern" : "^(Business|Individual)$"
    },
    "accountNumber" : {
      "type" : "string",
      "description" : "Required for Wires"
    },
    "localAccountNumber" : {
      "type" : "string",
      "description" : "Required for iACH"
    }
  }
}

这是我们为最终转换所写的内容,但它不起作用:

    "properties": {
        "identifier": "timetrail",
        "templateData": {
            "beneData": {
                "beneSpecific": {
                    "name": "john",
                    "classification": "Individual",
                    "accountnumber": "3243244",
                    "localAccountNumber": ""
                }

            }

        }

    }
}

所以,我们想知道这里出了什么问题。

标签: jsonamazon-web-servicesapiaws-api-gatewayapi-gateway

解决方案


推荐阅读