导出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. 正整数序列 Help the needed for Dexter ,UVa 11384

    题目描述 Description 给定正整数n,你的任务是用最少的操作次数把序列1, 2, …, n中的所有数都变成0.每次操作可从序列中选择一个或多个整数,同时减去一个相同的正整数.比如,1,2,3 ...

  2. hdu 2132... 被基本问题考住了。。

    Problem Description We once did a lot of recursional problem . I think some of them is easy for you ...

  3. 2019年全国高校sql数据库

    2019年全国高校名单sql数据库信息: 根据教育部发布的文件整理形成可用.sql文件,导入数据库即可使用. 包括全国高等学校共计2956所,其中:普通高等学校2688所(含独立学院257所),成人高 ...

  4. vs项目模板创建和使用

    一.使用dotnet命令创建(适用于.NET Core,可以创建包含任意数量个项目的模板,但不会出现在vs的新建项目模板中) 官方文档:https://docs.microsoft.com/zh-cn ...

  5. 在Windows平台搭建C语言开发环境

    一.在Windows平台搭建DEV C++集成开发环境     官网 https://sourceforge.net/projects/orwelldevcpp/ 中下载Dev C++运行即可 环境准 ...

  6. MongoDB安装及环境配置

    一.什么是MongoDB MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统. 在高负载的情况下,添加更多的节点,可以保证服务器性能. MongoDB 旨在为WEB应用提供 ...

  7. C# 字符串按设置的格试在前面或后面增加空格或其它字符

    public string lengadd(string stringa, string stringb, int count, int mode) //以stringa的长度,未到count的长度则 ...

  8. TODO-依赖注入与控制反转

    交互框架之Actor与Listener的关系 https://www.cnblogs.com/mq0036/p/7473371.html

  9. 【转载】 C#使用string.Join快速用特定字符串串联起数组

    在C#中有时候我们的数组元素需要通过一些特定的字符串串联起来,例如将整形Int数组通过逗号快速串联起来成为一个字符串,可以使用String.Join方法.或者一个字符串string类型数组所有元素快速 ...

  10. 判断上传文件是否为excel

    1. 可以在input上传组件上添加属性accept,这样上传文件的时候,就只能选择excel文件了. <input type="file" accept="app ...