我如何使用无服务器框架中的多个路径参数

How can i use multiple path parameters from serverless framework

我正在尝试部署我的无服务器应用程序。 但是遇到如下问题

An error occurred: ApiGatewayResourceServicesServiceidVar - A sibling ({id}) of this resource already has a variable path part -- only one is allowed  

下面是我的代码。

updateApplication:
    handler: handler.updateApplication
    memorySize: 3008
    description: Update application
    timeout: 30
    events:
      - http:
          path: services/{serviceId}/applications/{applicationId}
          method: post
          cors: true
          authorizer: authorize
          request:
            parameters:
              paths:
                serviceId: true
                applicationId: true

如有任何意见或建议,我们将不胜感激。提前谢谢你。

无服务器框架似乎在抱怨您定义了两次路径参数。由于您已在 -http: 正下方声明了它,因此您可以删除 request: parameters: paths: 块。

换句话说,试试这个:

updateApplication:
    handler: handler.updateApplication
    memorySize: 3008
    description: Update application
    timeout: 30
    events:
      - http:
          path: services/{serviceId}/applications/{applicationId}
          method: post
          cors: true
          authorizer: authorize

编码愉快!