将数据传递到 AWS API 网关时如何有点倾斜?
how to have a bit of obliqueness when passing data to AWS API Gateway?
我有一个 iOS 应用程序,它从服务器获取数据 "profile",并将其与另一个值 "appKnowsThisKey" 一起发送到 API 网关。
我希望 iOS 应用程序对 "profile" 的结构保持不可知。
我在 API 网关上创建了一个模型,它知道字典的键。
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "ExampleModel",
"type": "object", "properties": {
"appKnowsThisKey" : {"type": "string" },
"profile": {
"type": "object", "properties": {
"key1": {"type": "string" },
"key2": {"type": "string" },
"key3": {
"type": "array", "items": {"type": "string" }
}
}
}
}}
API 到 iOS 的网关部署已创建 Swift 类:ExampleModel
和 ExampleModel_profile
我在 iOS 应用程序中有一个对象 profile
保存 [String:AnyObject]
中的值。
如何将 iOS 中的字典分配给配置文件的 API 网关模型?例如,我是否将 ExampleModel 中的 "profile" 重新定义为 string
并传入 JSON 字符串?
如果您想让 iOS 应用程序与 "profile" 的结构无关,唯一的方法是在 ExampleModel 中将 "profile" 定义为字符串并传递一个 JSON 字符串。
将来结构发生变化时,您可以使用集成请求映射模板将 JSON 映射到端点期望的样子。
{
"someNewField" : "$input.json('$.profile.someOldField')"
}
我有一个 iOS 应用程序,它从服务器获取数据 "profile",并将其与另一个值 "appKnowsThisKey" 一起发送到 API 网关。
我希望 iOS 应用程序对 "profile" 的结构保持不可知。
我在 API 网关上创建了一个模型,它知道字典的键。
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "ExampleModel",
"type": "object", "properties": {
"appKnowsThisKey" : {"type": "string" },
"profile": {
"type": "object", "properties": {
"key1": {"type": "string" },
"key2": {"type": "string" },
"key3": {
"type": "array", "items": {"type": "string" }
}
}
}
}}
API 到 iOS 的网关部署已创建 Swift 类:ExampleModel
和 ExampleModel_profile
我在 iOS 应用程序中有一个对象 profile
保存 [String:AnyObject]
中的值。
如何将 iOS 中的字典分配给配置文件的 API 网关模型?例如,我是否将 ExampleModel 中的 "profile" 重新定义为 string
并传入 JSON 字符串?
如果您想让 iOS 应用程序与 "profile" 的结构无关,唯一的方法是在 ExampleModel 中将 "profile" 定义为字符串并传递一个 JSON 字符串。
将来结构发生变化时,您可以使用集成请求映射模板将 JSON 映射到端点期望的样子。
{
"someNewField" : "$input.json('$.profile.someOldField')"
}