首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >Aws lambda代理Swagger模板集成

Aws lambda代理Swagger模板集成
EN

Stack Overflow用户
提问于 2019-05-08 04:21:09
回答 1查看 617关注 0票数 3

我正试图建立一个自大的模板来调用我的全部在一个λ。

假设在processlambda下面有两个“函数”。这是一个正确的openapi 3.0模板,还是必须专门配置请求类型和响应类型?

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
{
   "openapi": "3.0.0",
   "info": {
      "version": "2016-09-12T17:50:37Z",
      "title": "ProxyIntegrationWithLambda"
   },
   "paths": {
      "/GetItemById": {
         "x-amazon-apigateway-any-method": {
            "parameters": [
               {
                  "name": "proxy",
                  "in": "path",
                  "required": true,
                  "schema": {
                     "type": "string"
                  }
               }
            ],
            "responses": {},
            "x-amazon-apigateway-integration": {
               "responses": {
                  "default": {
                     "statusCode": "200"
                  }
               },
               "uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789012:function:SimpleLambda4ProxyResource/invocations",
               "passthroughBehavior": "when_no_match",
               "httpMethod": "POST",
               "cacheNamespace": "roq9wj",
               "cacheKeyParameters": [
                  "method.request.path.proxy"
               ],
               "type": "aws_proxy"
            }
         }
      }
   },
      "/SaveItem": {
         "x-amazon-apigateway-any-method": {
            "parameters": [
               {
                  "name": "proxy",
                  "in": "path",
                  "required": true,
                  "schema": {
                     "type": "string"
                  }
               }
            ],
            "responses": {},
            "x-amazon-apigateway-integration": {
               "responses": {
                  "default": {
                     "statusCode": "200"
                  }
               },
               "uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789012:function:SimpleLambda4ProxyResource/invocations",
               "passthroughBehavior": "when_no_match",
               "httpMethod": "POST",
               "cacheNamespace": "roq9wj",
               "cacheKeyParameters": [
                  "method.request.path.proxy"
               ],
               "type": "aws_proxy"
            }
         }
      }
   },
   "servers": [
      {
         "url": "https://gy415nuibc.execute-api.us-east-1.amazonaws.com/{basePath}",
         "variables": {
            "basePath": {
              "default": "/Process"
            }
         }
      }
   ]
}

尚未对此进行测试,但C#函数代码使用APIGateway响应/请求标准aws对象

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-08 07:37:45

作为另一种选择,您可以使用的一个好路径是配置您的API (指向AWS ),然后从API配置中生成您的openapi规范,然后生成您的c#客户机。

配置了After之后,您可以运行以下步骤:

运行出口,例如:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
aws apoigateway get-export 
  --rest-api-id 'idfromapigateway-grab-inside-awsdashboard' 
  --stage-namem 'stage-grab-inside-awsdashboard' 
  --export-type 'swagger' outputfile-with-openapispec-generated-step1.json

步骤2) 生成客户端,例如:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
nswag swagger2csclient /input:outputfile-with-openapispec-generated-step1.json
  /classname:SpecifyYourCSharpClassName
  /namespace:SpecifyYourCSharpNamespace
  /output:SpecifyYourCSharpFile

步骤2的结果生成可用于集成测试的c#类。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56040691

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文