AWS API Gateway Swagger定义
导出Swagger接口定义文件
在AWS API Gateway界面上,可以导出swagger接口定义文件。
而后利用Node js swagger-ui 依赖,生成swagger接口地址
CloudFormation模版配置API Gateway参数
对于RequestBody配置方式
例:给该method配置RequestModels
MethodPostForUpdateDraftToCurrentVersion:
Type: 'AWS::ApiGateway::Method'
Properties:
HttpMethod: POST
RequestModels:
application/json: UpdateDraftToCurrentVersionModel
ResourceId: !Ref ResourceDocumentUpdateDraftToCurrentVersion
RestApiId: !Ref RestApiDDTM
AuthorizationType: NONE
Integration:
Type: AWS_PROXY
IntegrationHttpMethod: POST
Uri: !Sub
- arn:aws-cn:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${FnArn}:${FnVersion}/invocations
- {FnArn : !Ref functionArn,FnVersion : '${stageVariables.version}'}
IntegrationResponses:
- StatusCode: 200
MethodResponses:
- StatusCode: 200
ResponseModels:
application/json: Empty
UpdateDraftToCurrentVersionModel:
Type: "AWS::ApiGateway::Model"
Properties:
RestApiId:
Ref: RestApiDDTM
ContentType: "application/json"
Description: "request body for UpdateDraftToCurrentVersion"
Name: UpdateDraftToCurrentVersionModel
Schema:
"$schema": "http://json-schema.org/draft-04/schema#"
title: UpdateDraftToCurrentVersionModel
type: object
properties:
params:
type: object
properties:
userId:
type: integer
documentId:
type: integer
companyId:
type: integer
documentVersionId:
type: integer
templates:
type: array
items:
type: object
properties:
contentType:
type: string
locale:
type: string
content:
type: string
textContent:
type: string
fileContent:
type: string 生成swagger API后,实际上的requestBody为:
{
"userId":integer,
"documentId":integer,
"companyId":integer,
"documentVersionId":integer,
templates:[
{
"contentType":"string",
"locale":"string",
"content":"string",
"textContent":"string",
"fileContent":"string"
}
]
}
对于RequestParam配置方式
请求路径:/document/listDocSamplePage?page=1&pageSize=&query=
增加RequestParameters参数
keywmethod.request.querystring.{paramName}
MethodGetForListDocSamplePage:
Type: 'AWS::ApiGateway::Method'
Properties:
HttpMethod: GET
RequestParameters:
method.request.querystring.page: false
method.request.querystring.pageSize: false
method.request.querystring.query: false
生成Swagger API效果:
对于PathVaribles配置方式
请求路径:/document/findFullDocSample/{id}
增加RequestParameters参数
key:method.request.path.{pathVariableName}
value:值是否必须
MethodGetForFindFullDocSampleId:
Type: 'AWS::ApiGateway::Method'
Properties:
HttpMethod: GET
RequestParameters:
method.request.path.id: true Swagger Api 效果:
AWS API Gateway Swagger定义的更多相关文章
- 基于aws api gateway的asp.net core验证
本文是介绍aws 作为api gateway,用asp.net core用web应用,.net core作为aws lambda function. api gateway和asp.net core的 ...
- Aws api gateway Domain name
Set Up a Custom Domain Name for an API Gateway API The following procedure describes how to set up a ...
- Amazon API Gateway Importer整合过程小结
(1)需要将swagger json转换成amazon api gateway 所需要的格式(根据Method Request中 Request PathsURL Query String Param ...
- gRPC helloworld service, RESTful JSON API gateway and swagger UI
概述 本篇博文完整讲述了如果通过 protocol buffers 定义并启动一个 gRPC 服务,然后在 gRPC 服务上提供一个 RESTful JSON API 的反向代理 gateway,最后 ...
- Qwiklab'实验-API Gateway, AWS Lambda'
title: AWS之Qwiklab subtitle: 2. Qwiklab'实验-API Gateway, AWS Lambda' date: 2018-09-20 17:29:20 --- In ...
- How to return plain text from AWS Lambda & API Gateway
With limited experience in AWS Lambda & API Gateway, it's struggling to find the correct way to ...
- 使用AWS Lambda,API Gateway和S3 Storage快速调整图片大小
https://www.obytes.com/blog/2019/image-resizing-on-the-fly-with-aws-lambda,-api-gateway,-and-s3-stor ...
- AWS lambda DynamoDB api gateway之间的连接
创建角色 附加策略 AmazonDynamoDBFullAccess AWSLambdaDynamoDBExecutionRole 创建DynamoDB表 在表的项目中创建内容 this pipi 打 ...
- Using Amazon API Gateway with microservices deployed on Amazon ECS
One convenient way to run microservices is to deploy them as Docker containers. Docker containers ar ...
随机推荐
- C#进阶系列——WebApi接口返回值类型详解
阅读目录 一.void无返回值 二.IHttpActionResult 1.Json(T content) 2.Ok(). Ok(T content) 3.NotFound() 4.其他 5.自定义I ...
- jmeter接口测试中的用例数据分离
用jmeter做接口测试的话,一个jmx文件就可以是一个用例,而用例的设计多数还是等价类.边界值等方法.用例越来越多的时候,维护比较麻烦,所以可以把用例的数据存在csv文件中,然后通过组件(CSV D ...
- Math.random()的加密安全替换方法window.crypto.getRandomValues
Math.random() 返回介于 0(包含) ~ 1(不包含) 之间的一个随机数. Math.random()函数不是加密安全的随机数生成器. window.crypto.getRandomVal ...
- ASP.NET MVC 5 伪静态之支持*.html路由
参考了例子 到自己实践还是有不少坑要踩,这种文章,你说它好还是不好呢 注意这里的版本是ASP.NET MVC 5 首页的URL为 http://localhost:58321/index.html ...
- NoSql 使用小结
NoSql 使用小结 足够的冗余 如果出现要拿某个 id 去查另外的 collection 的情况,说明应该往这个增加所要查询的字段 实在要做关联查询的话,是不是应该考虑关系型的数据库,关系和非关系混 ...
- NetCore.SignalR.Demo演示
项目github,点击https://github.com/wangpengzong/NetCore.SignalR.Demo 1.打开服务端Server(\SignalR.Server\bin\De ...
- Linux查找文件之Find命令
Linux系统文件中常用属性包括以下内容:名称,大小,权限,属主,属组,修改时间,访问时间等.在庞大的Linux系统中查询文件,需要借助查找工具来实现,依此可以查询相同或指定属性的文件,本文所讲的查询 ...
- 安卓开发之cache 的使用(图片查看器案例)
package com.lidaochen.test; import android.graphics.Bitmap; import android.graphics.BitmapFactory; i ...
- sql将查询结果的某个字段赋值给另一个字段
Update a set a.NickName=b.name FROM AccountsInfo a, TT b where a.UserID=b.userId 必须要有关联的两个表
- 运维开发笔记整理-使用Django编写helloworld
运维开发笔记整理-使用Django编写helloworld 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.创建Django项目 1>.创建Django项目 djang ...