如何在为我的 AWS API 网关生成的 SDK 中设置请求路径参数

How do I set request path parameters in the generated SDK for my AWS API Gateway

如何在我创建的 API 网关 SDK 中设置请求路径参数?

我有一个这样的 PUT 请求:/users/{id}

当我在 API 网关 GUI 中测试它时,它工作得很好。我被要求提供 ID 参数。

但是当我创建 SDK 时,我得到以下方法 (Android/Java):

@Operation(
    path = "/users/{id}",
    method = "PUT"
)
void usersIdPut(UserPut var1);

我无法更改路径。它会调用 URL 和 {id} 字面意思。

我试过将 ID 放入 UserPut 模型中,但没有区别。

我该怎么做?

我无法重现该问题,我在方法上有一个请求模型、响应模型和一个路径参数,我从 SDK 客户端获得:

    @Operation(
        path = "/mappingtest/{id}",
        method = "GET"
    )
    Empty mappingtestIdGet(@Parameter(
    name = "id",
    location = "path"
) String var1, Empty var2);

您能否检查以确保参数已在方法请求的 'Request Paths' 部分中定义?而且您已经部署了最新的更改,因为 SDK 是在已部​​署的阶段构建的。

我运行遇到了同样的问题,原来问题是我使用的是无服务器框架,它没有设置"requestParameter"字段来标记路径参数。例如{"method.request.path.id": true}

来自文档 (http://docs.aws.amazon.com/cli/latest/reference/apigateway/put-method.html):

requestParameters -> (map) A key-value map defining required or optional method request parameters that can be accepted by Amazon API Gateway. A key is a method request parameter name matching the pattern of method.request.{location}.{name} , where location is querystring , path , or header and name is a valid and unique parameter name. The value associated with the key is a api-key-required flag indicating whether the parameter is required (true ) or optional (false ). The method request parameter names defined here are available in Integration to be mapped to integration request parameters or templates.

在从 github 源而不是发行版安装无服务器框架后,我能够让它工作,发行版最近为请求参数字段添加了 support