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 ...
随机推荐
- springboot注册到consul中报错:Spring MVC found on classpath, which is incompatible with Spring Cloud
今天在做springboot整合成springCloud并注册到consul中时,发现若注册到consule中成功 则不能启动swagger,且不能提供任何API服务,要是能提供API服务则不能注册到 ...
- 在论坛中出现的比较难的sql问题:46(日期条件出现的奇怪问题)
原文:在论坛中出现的比较难的sql问题:46(日期条件出现的奇怪问题) 最近,在论坛中,遇到了不少比较难的sql问题,虽然自己都能解决,但发现过几天后,就记不起来了,也忘记解决的方法了. 所以,觉得有 ...
- 在论坛中出现的比较难的sql问题:29(row_number函数 组内某列的值连续出现3次标记出来)
原文:在论坛中出现的比较难的sql问题:29(row_number函数 组内某列的值连续出现3次标记出来) 在论坛中,遇到了不少比较难的sql问题,虽然自己都能解决,但发现过几天后,就记不起来了,也忘 ...
- hibernate注解(自动建表如何有表DDL注释) -- Comment用法
import java.io.Serializable; import java.sql.Date; import java.sql.Timestamp; import javax.persisten ...
- ELK文档--ELK简介
请参考:http://www.cnblogs.com/aresxin/p/8035137.html
- 虚拟机安装master,克隆slave0、slave1(多台机相连,网络匹配)
1.在虚拟机中创建一个名叫master的主机 2.创建成功后,打开编辑选项——虚拟网络网络编辑器,填网关 3.打开终端,进入root权限,编写命令 设置虚拟机DNS 4.给master网络配置好后,克 ...
- Android笔记(十九) Android中的Fragment
通常我们使用Activity来展示界面,但是在手机上界面可能显示的很好看,但在平板上,因为平板的屏幕非常大,手机的界面放在平板上可能会出现控件被拉长.控件之间间距变大等问题.为了更好的体验效果,在Ac ...
- WCF服务代理类-学习
类:ServiceDescriptionImporter Class 公开一种为 XML Web services 生成客户端代理类的方法. 地址:https://docs.microsoft.com ...
- Thread.sleep()和Thread.currentThread().sleep()区别
先看一下代码 public class Thread1 extends Thread{ @Override public void run() { try { System.out.println(& ...
- 并发编程大师系列之:线程的定义和中断 interrupt
1.启动线程的三种方式: 1.1继承Thread类 public static class UseThread extends Thread { public void run() { System. ...