导出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定义的更多相关文章

  1. 基于aws api gateway的asp.net core验证

    本文是介绍aws 作为api gateway,用asp.net core用web应用,.net core作为aws lambda function. api gateway和asp.net core的 ...

  2. 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 ...

  3. Amazon API Gateway Importer整合过程小结

    (1)需要将swagger json转换成amazon api gateway 所需要的格式(根据Method Request中 Request PathsURL Query String Param ...

  4. gRPC helloworld service, RESTful JSON API gateway and swagger UI

    概述 本篇博文完整讲述了如果通过 protocol buffers 定义并启动一个 gRPC 服务,然后在 gRPC 服务上提供一个 RESTful JSON API 的反向代理 gateway,最后 ...

  5. Qwiklab'实验-API Gateway, AWS Lambda'

    title: AWS之Qwiklab subtitle: 2. Qwiklab'实验-API Gateway, AWS Lambda' date: 2018-09-20 17:29:20 --- In ...

  6. 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 ...

  7. 使用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 ...

  8. AWS lambda DynamoDB api gateway之间的连接

    创建角色 附加策略 AmazonDynamoDBFullAccess AWSLambdaDynamoDBExecutionRole 创建DynamoDB表 在表的项目中创建内容 this pipi 打 ...

  9. 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 ...

随机推荐

  1. 初试牛刀:实时天气WebService

    1.引入WebService:http://www.webxml.com.cn/WebServices/WeatherWebService.asmx 2.声明接口→界面获取值传入接口→接口返回值处理→ ...

  2. 【SoloPi】SoloPi使用4-功能使用,一机多控

    Soloπ是什么Soloπ是一个无线化.非侵入式的Android自动化工具,公测版拥有录制回放.性能测试.一机多控三项主要功能,能为测试开发人员节省宝贵时间. 一机多控功能Soloπ支持通过操作一台主 ...

  3. 为Visual Studio安装其他控件(cognex 康耐视)时报错:未能加载文件或程序集 EnvDTE, Version=8.0.0.0

    解决办法: 在VS的路径下(一般为:C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Private ...

  4. ivew数控件Tree自定义节点内容示例分析

    ivew数控件Tree自定义节点内容示例分析 demo地址:https://run.iviewui.com/plcWlM4H <template> <Tree :data=" ...

  5. Go part 6 接口,接口排序,接口嵌套组合,接口与类型转换,接口断言

    接口 接口是一种协议,比如一个汽车的协议,就应该有 “行驶”,“按喇叭”,“开远光” 等功能(方法),这就是实现汽车的协议规范,完成了汽车的协议规范,就实现了汽车的接口,然后使用接口 接口的定义:本身 ...

  6. java输出月的日历控制台

    LocalDate date=LocalDate.now(); int month=date.getMonthValue(); int today=date.getDayOfMonth(); date ...

  7. UI5-技术篇-SAPUI5创建自定义控件

    转载:https://www.nabisoft.com/tutorials/sapui5/creating-custom-controls-in-sapui5     https://sapui5.h ...

  8. 简述FTP的主动模式与被动模式(精简)

    一.主被动 主动: 客户端从任意一个大于1024的端口现在假设为1234(非特权端口)连接到服务端的21端口(命令端口),随之客户端监听端口(N+1)即为1235端口(可以理解为这是客户端认定的数据端 ...

  9. 记录java+testng运行selenium(一)

    整体的流程为下图 整体思路为: 1. 由程序开始运行时去读取ini文件中存储的浏览器及需要打开的url 2. test运行时通过description实现数据驱动,主要做两件事 2.1 第一件事为:读 ...

  10. Windows Server 2008更改SID

    参考:Windows Server 2012 克隆修改SID 前言 克隆(软克隆,硬克隆)虚拟机后,虚拟机不光名称一样,IP一样(设置静态IP情况下),连SID也一样 什么是SID SID 安全标识符 ...