将Swagger或OpenAPI定义的API导入到API网关,支持导入到新分组和导入到已有分组两种方式。导入前,您需要了解APIG的兼容性说明,并在API定义中补全API网关的扩展定义。
约束与限制
- API网关参数限制:
- 暂不支持formData和body位置的请求参数定义。
- 暂不支持consumes和produces定义。
- header位置的参数名称,不区分大小写。
- 后端策略限制:
- 默认后端类型为HTTP时,策略后端支持HTTP、HTTP-VPC。
- 默认后端类型为HTTP-VPC时,策略后端支持HTTP、HTTP-VPC。
- 默认后端类型为function时,策略后端支持function。
- 默认后端类型为mock时,策略后端支持mock。
- API网关中API分组和API的配额满足需求。
- 如果使用Swagger info或OpenAPI info的title作为API分组名称,新创建的API分组名称不能与已有的API分组名称重名。
- 导入的API定义中,如果存在冲突,那么根据系统导入的先后顺序,先导入的API会显示导入成功,后导入的API会显示导入失败。例如导入的API定义中存在2个名称相同或请求路径相同的API,那么先导入的API会显示导入成功,后导入的会显示导入失败。
- 导入的API定义与已有的API定义冲突时,您可以选择使用导入的API定义覆盖已有的API定义,或者保留已有的API定义,此时导入的API定义会显示导入失败。
- 如果选择扩展覆盖,当导入API的扩展定义项名称与已有策略(ACL,流量控制等)名称相同时,则会覆盖已有策略(ACL,流量控制等)。
- 导入的API不会自动发布到环境,导入时可以选择“立即发布”或者“稍后发布”,您可以自行选择策略。
- 暂不支持导入GRPC API、API的负载通道、SSL证书和凭据。
导入API设计文件
- 进入API网关控制台页面。
- 根据实际业务在左侧导航栏上方选择实例。
- 支持通过以下路径导入API。
- 在左侧导航栏选择“API管理 > API分组”。单击“创建API分组 > 导入API设计文件”。
- 在左侧导航栏选择“API管理 > API列表”。单击“导入API”。
- 在弹窗中选择本地路径下的API文件,然后单击“打开”导入文件。
- 根据下表参数说明,填写导入信息。
表1 导入API | 参数名称 | 说明 |
| 导入方式 | 导入方式包含以下2种: - 生成新的分组:将API定义导入到一个新的分组,导入过程中系统会自动创建一个新的API分组,并将导入的API归属到该分组。
- 选择已有分组:将API定义导入到一个已有的分组,导入过程中不会删除分组中已有的API,只是将新增的API导入分组。
|
| API分组 | 仅在导入方式选择“选择已有分组”时,需要选择API分组。 |
| 是否覆盖 | 仅在导入方式选择“选择已有分组”时,可以勾选“是否覆盖”。勾选后,当导入的API名称与已有的API名称相同时,导入的API会覆盖已有的API。 |
| 扩展覆盖 | 仅在导入方式选择“生成新的分组”时,可以勾选“扩展覆盖”。勾选后,当导入API扩展定义项名称(ACL,流控等)与已有的策略(ACL,流控等)名称相同时,会覆盖已有的策略(ACL,流控等)。 |
- (可选)单击“全局配置(可选)”。
- 安全配置。
请参考下表参数说明配置。
表2 安全配置 | 参数 | 说明 |
| 类型 | API类型: - 公开:选择“公开”类型时,API支持上架。
- 私有:选择“私有”类型时,当该API所在分组上架时,该API不会上架。
|
| 安全认证 | API认证方式: 各种认证方式下的API调用稍有不同,详情请参考调用APIG开放的API章节。 注意: - 认证方式为华为IAM认证时,任何API网关租户均可以访问此API,可能存在恶意刷流量,导致过量计费的风险。
- 认证方式为无认证时,任何公网用户均可以访问此API,可能存在恶意刷流量,导致过量计费的风险。
- 认证方式为自定义认证时,需要在函数服务中写一段函数,对接用户自己的认证系统或服务。如果当前Region没有上线函数工作流服务,则不支持自定义认证。
|
| 支持简易认证 | 仅当“安全认证”选择“APP认证”时可配置。 简易认证指APP认证方式下调用API时,在HTTP请求头部消息增加一个参数X-Apig-AppCode,而不需要对请求内容签名,API网关也仅校验AppCode,不校验请求签名,从而实现快速认证。 注意支持HTTPS方式调用,不支持HTTP方式。具体使用请参考配置APIG的API简易认证AppCode章节。 说明: 如果首次创建API未开启简易认证,那么之后开启简易认证,需要重新发布API。请参考发布APIG创建的API章节发布。 |
| 支持双重认证 | 仅当“安全认证”选择“APP认证”或“华为IAM认证”时可配置。 是否对API的调用进行双重安全认证。如果选择启用,则在使用APP认证或IAM认证对API请求进行安全认证时,同时使用自定义的函数API对API请求进行安全认证。 |
| 自定义认证 | 仅当“安全认证”选择“自定义认证”时需要配置。 选择已创建的前端类型自定义认证。若没有可用的自定义认证,可单击右侧的“新建自定义认证”,创建一个前端类型的自定义认证。 |
| 支持跨域CORS | 是否开启跨域访问CORS(cross-origin resource sharing)。 CORS允许浏览器向跨域服务器,发出XMLHttpRequest请求,从而克服了AJAX只能同源使用的限制。 CORS请求分为两类: - 简单请求:头信息之中,增加一个Origin字段。
- 非简单请求:在正式通信之前,增加一次HTTP查询请求。
开启CORS(非简单请求)时,您需要单独创建一个“请求方法”为“OPTIONS”的API,具体操作请参考开启跨域访问章节。 |
| 链路追踪 | 是否开启链路追踪,默认关闭。开启后,网关会基于W3C Trace Context协议规范向后端传递请求头traceparent并记录链路追踪字段到请求日志中。 - 当前仅北京四、广州、上海一、上海二、新加坡、利雅得区域支持链路追踪功能。
- 查看调用链以及业务拓扑,需要配置调用日志,选择APM应用。
|
| 采样策略 | 仅当开启“链路追踪”时可配置。 当前仅支持“按比例采样”策略,按比例采样指从所有请求中按百分比抽取一部分来追踪记录。 |
| 采样比例 | 仅当开启“链路追踪”时可配置。 从所有请求中,抽取多少比例来追踪记录。取值为0-100的整数,默认为100,100为采集每个请求,建议与后端服务的采样率保持一致。 |
- 后端请求配置。
请参考下表参数说明,选择API后端服务类型并配置信息。
- HTTP&HTTPS类型
表3 HTTP&HTTPS类型定义后端服务 | 参数 | 说明 |
| 负载模式 | 是否使用负载通道访问后端服务。 负载模式分为以下几种: - 不使用:指不使用负载通道访问后端服务,直接通过后端服务地址访问后端服务。
- 单模后端:指使用负载通道访问后端服务,并且支持对同一负载通道的不同服务器分组配置相同的请求协议、请求方法和路径。
- 多模后端:指使用负载通道访问后端服务,并且支持对同一负载通道的不同服务器分组配置不同的请求协议、请求方法和路径。
- 多模后端模式受限使用,如需使用,请提交工单开通。
- 多模后端模式仅在后端服务类型为HTTP&HTTPS时可以选择。
- 多模后端模式下,参数编排对所有服务器分组的不同URL同时生效,无法分开配置。
- 多模后端模式下,系统参数member_group_id和member_group_name在断路器(降级参数配置)插件策略中不生效。
|
| URL | URL地址由请求方法、请求协议、负载通道/后端服务地址和路径组成。 - 请求方法
GET、POST、DELETE、PUT、PATCH、HEAD、OPTIONS、ANY,其中ANY表示该API支持任意请求方法。 - 请求协议
HTTP或HTTPS,传输重要或敏感数据时推荐使用HTTPS。 - API网关支持WebSocket数据传输,请求协议中的HTTP相当于WebSocket的ws,HTTPS相当于WebSocket的wss。
- 定义的后端服务协议须与用户的后端业务协议保持一致。
- 后端服务地址
仅在不使用负载通道时,需要设置。 填写后端服务的访问地址,格式:“主机:端口”。主机为后端服务的访问IP地址/域名;端口为后端服务的端口。未指定端口时,HTTP协议默认使用80端口,HTTPS协议默认使用443端口。 如果后端服务地址中需要携带环境变量,则使用“#变量名#”的形式将环境变量添加到后端服务地址中,如#ipaddress#。支持添加多个环境变量,如#ipaddress##test#。 说明: IP地址/域名可以是公网IP(支持云服务器的弹性IP地址、用户自己服务器的公网IP地址、ELB地址)/公网域名,前提需要开启实例的公网出口。可以是内网的IP,不可以是内网域名。 2022年10月30日后创建的实例支持APIG与后端服务tls握手阶段向后端服务传SNI。 - 负载通道
仅在使用负载通道(单模后端)时,需要设置。选择已创建的负载通道名称,或者新建负载通道。 负载通道中,云服务器的安全组必须允许100.125.0.0/16网段访问,否则将导致健康检查失败及业务不通。 - 路径
后端服务的路径,即服务的uri,可以包含路径参数,以{路径参数}形式表示,比如/getUserInfo/{userId}。 如果请求路径中含有环境变量,则使用#变量名#的方式将环境变量定义到请求路径中,如/#path#。支持创建多个环境变量,如/#path##request#。 说明: - 在URL中配置了变量标识后,在API调试页面将无法调试。
- 如果在URL中设置变量,那么必须在待发布环境上配置变量名和变量值,否则变量无法赋值,API将无法正常调用。
- 变量名严格区分大小写。
|
| 选择负载通道 | 仅在使用负载通道(多模后端)时,需要设置。选择已创建的负载通道名称,或者新建负载通道。 |
| 服务器分组信息 | 仅在使用负载通道(多模后端)时,需要设置。 单击“添加服务器分组”,设置服务器分组信息。 - 服务器分组只能选择指定负载通道中配置的服务器分组,可以添加的服务器分组数量对应负载通道中配置的服务器分组数量。
- 请求协议、请求方法和路径与上述“URL”参数中的请求协议、请求方法和路径一致。
|
| 自定义host头域 | 仅在使用负载通道(单模后端)时,可设置。 自定义后端服务请求中的Host头域,默认使用请求中原始的host头域。 |
| 后端超时(ms) | 后端服务请求的超时时间,可填写范围1ms~60000ms。 如果在API调试过程中,遇到后端响应超时之类的错误,请适当调大后端超时时间,以便排查原因。 说明: 如果当前的超时时间范围不能满足实际业务需求,请在实例配置参数中修改超时时间上限,可修改范围为1ms~600000ms。如果您修改了超时时间上限,需要同步修改此处的超时时间。 |
| 重试次数 | 后端服务请求失败后的重试次数,默认值为0,取值范围-1~10。 - 值为-1时,表示不开启重试功能,但除POST和PATCH外的其他请求类型会默认重试1次。
- 值为0~10时,表示开启重试功能,并根据设置的值执行重试。当值为0时,不重试。
使用负载通道时,重试次数应小于负载通道中已启用的后端服务器个数。 |
| TLS双向认证 | 仅在协议为“HTTPS”时,可设置。 选择是否在API网关和后端服务间启用双向认证,如果选择“使用backend_client_certificate配置的证书做客户端认证”,您需在实例的配置参数中提前配backend_client_certificate证书。 |
| 后端认证 | 当您的后端服务需要对API调用增加自己的认证,则开启后端认证。 后端认证需要先添加一个自定义认证,自定义认证通过函数服务实现,在函数服务中编写一个函数,实现您的认证鉴权流程,或者使用函数调用您的统一鉴权服务。 |
- FunctionGraph类型
FunctionGraph依赖于函数工作流服务FunctionGraph,如果当前环境中未部署FunctionGraph服务,则FunctionGraph类型不可用。
表4 FunctionGraph类型定义后端服务 | 参数 | 说明 |
| 函数名 | 添加函数后,函数名自动生成。 |
| 函数URN | 函数请求唯一标识。 单击“添加”,添加所需的函数URN。 |
| 版本或别名 | 选择函数的版本或别名,函数的版本或别名功能请参考版本管理章节或别名管理章节。 |
| 网络架构 | 选择函数网络架构。网络架构受限,如需使用,请提交工单开通。 - V1:对接函数的非VPC架构
- V2:对接函数的VPC架构
|
| 调用类型 | 选择函数的调用类型。 - Synchronous:同步调用。指后端函数服务收到调用请求后立即执行并返回调用结果,客户端发送请求后同步等待,收到后端响应后关闭连接。
- Asynchronous:异步调用。客户端不关注请求调用的结果,服务端收到请求后将请求排队,排队成功后请求就返回,服务端在空闲的情况下会逐个处理排队的请求。
|
| 后端超时(ms) | 后端服务请求的超时时间,可填写范围1ms~60000ms。 - 如果在API调试过程中,遇到后端响应超时之类的错误,请适当调大后端超时时间,以便排查原因。
- 如果当前的超时时间范围不能满足实际业务需求,请在实例配置参数中修改超时时间上限,可修改范围为1ms~600000ms。如果您修改了超时时间上限,需要同步修改此处的超时时间。
函数网络架构为“V1”时最大超时时间为60000ms,“V2”时最大超时时间可通过实例特性参数backend_timeout配置修改,可修改的上限为600000ms。 |
| 后端认证 | 当您的后端服务需要对API调用增加自己的认证,则开启后端认证。 后端认证需要先添加一个自定义认证,自定义认证通过函数服务实现,在函数服务中编写一个函数,实现您的认证鉴权流程,或者使用函数调用您的统一鉴权服务。 |
- Mock类型
在后端服务还不具备的场景下,可以使用Mock类型,将预期结果固定返回给API调用方,方便调用方进行调试验证。
表5 Mock类型定义后端服务 | 参数 | 说明 |
| Mock自定义返回码 | 选择API响应的HTTP状态码。 |
| Mock返回结果 | Mock一般用于开发调试验证。在项目初始阶段,后端服务没有搭建好API联调环境,可以使用Mock模式,将预期结果固定返回给API调用方,方便调用方进行项目开发。 |
| 后端认证 | 当您的后端服务需要对API调用增加自己的认证,则开启后端认证。 后端认证需要先添加一个自定义认证,自定义认证通过函数服务实现,在函数服务中编写一个函数,实现您的认证鉴权流程,或者使用函数调用您的统一鉴权服务。 |
| 添加常量参数 | 自定义API响应的header参数。 单击“添加常量参数”,并填写参数名、参数值和参数描述。 |
- 单击“下一步”,支持通过“表单”、“JSON”、“YAML”样式查看配置详情。
- 确认无误后,单击“提交”。
- 在弹窗中选择是否现在发布API到环境。
- 如果选择“现在发布”,还需要选择API要发布的环境,将API分组下的所有API发布到环境上。
- 如果选择“稍后发布”,发布API具体操作,请参考发布API章节。
- 单击“确定”,跳转到“API运行”页面,可查看分组下的API。
导入HTTP类型后端服务API示例
包含IAM认证和请求参数编排的GET方法API定义,后端服务类型为HTTP。
Swagger示例:
swagger: "2.0"
info:
title: "importHttpEndpoint10"
description: "import apis"
version: "1.0"
host: "api.account.com"
paths:
'/http/{userId}':
get:
operationId: "getUser3"
description: "get user by userId"
security:
- apig-auth-iam: []
schemes:
- https
parameters:
- name: "test"
description: "authorization token"
type: "string"
in: "header"
required: true
- name: "userId"
description: "user id"
type: "string"
in: "path"
required: true
responses:
"200":
description: "user information"
x-apigateway-request-type: "public"
x-apigateway-cors: true
x-apigateway-is-send-fg-body-base64: true
x-apigateway-match-mode: "NORMAL"
x-apigateway-backend:
type: "HTTP"
parameters:
- name: "userId"
value: "userId"
in: "query"
origin: "REQUEST"
description: "user id"
- name: "X-Invoke-User"
value: "apigateway"
in: "header"
origin: "CONSTANT"
description: "invoke user"
httpEndpoints:
address: "example.com"
scheme: "http"
method: "GET"
path: "/users"
timeout: 30000
securityDefinitions:
apig-auth-app:
in: header
name: Authorization
type: apiKey
x-apigateway-auth-type: AppSigv1
apig-auth-iam:
in: header
name: unused
type: apiKey
x-apigateway-auth-type: IAM
OpenAPI示例:
openapi: 3.0.0
info:
title: importHttpEndpoint10
version: '1.0'
servers:
- url: >-
http://abc.com
- url: >-
https://abc.com
paths:
'/http/{userId}':
get:
description: get user by userId
operationId: getUser3
parameters:
- description: authorization token
example: ''
in: header
name: test
required: true
schema:
maxLength: 0
maximum: 0
minimum: 0
type: string
x-apigateway-pass-through: always
- description: user id
example: ''
in: path
name: userId
required: true
schema:
maxLength: 0
maximum: 0
minimum: 0
type: string
x-apigateway-pass-through: always
responses:
default-cors:
description: response example
x-apigateway-result-failure-sample: ''
x-apigateway-result-normal-sample: ''
security:
- apig-auth-iam: []
servers:
- url: >-
https://abc.com
x-apigateway-backend:
httpEndpoints:
address: example.com
description: ''
enableClientSsl: false
method: GET
path: /users
retryCount: '-1'
scheme: http
timeout: 30000
parameters:
- description: invoke user
in: HEADER
name: X-Invoke-User
origin: CONSTANT
value: apigateway
- description: user id
in: QUERY
name: userId
origin: REQUEST
value: userId
type: HTTP
x-apigateway-cors: true
x-apigateway-is-send-fg-body-base64: true
x-apigateway-match-mode: NORMAL
x-apigateway-request-type: public
x-apigateway-response: default
components:
responses:
default-cors:
description: response example
headers:
Access-Control-Allow-Origin:
schema:
default: '*'
type: string
securitySchemes:
apig-auth-app:
in: header
name: Authorization
type: apiKey
x-apigateway-auth-type: AppSigv1
apig-auth-app-header:
in: header
name: Authorization
type: apiKey
x-apigateway-auth-opt:
appcode-auth-type: header
x-apigateway-auth-type: AppSigv1
apig-auth-iam:
in: header
name: unused
type: apiKey
x-apigateway-auth-type: IAM
x-apigateway-responses:
default: {} 导入HTTP VPC类型后端服务API示例
包含APP认证和请求参数编排的ANY方法API定义,后端服务使用VPC通道。
Swagger示例:
swagger: "2.0"
info:
title: "importHttpVpcEndpoint"
description: "import apis"
version: "1.0"
host: "api.account.com"
paths:
'/http-vpc':
x-apigateway-any-method:
operationId: "userOperation"
description: "user operation resource"
security:
- apig-auth-app: []
schemes:
- https
parameters:
- name: "Authorization"
description: "authorization signature"
type: "string"
in: "header"
required: true
responses:
"default":
description: "endpoint response"
x-apigateway-request-type: "public"
x-apigateway-cors: true
x-apigateway-is-send-fg-body-base64: true
x-apigateway-match-mode: "SWA"
x-apigateway-backend:
type: "HTTP-VPC"
parameters:
- name: "X-Invoke-User"
value: "apigateway"
in: "header"
origin: "CONSTANT"
description: "invoke user"
httpVpcEndpoints:
name: "userVpc"
scheme: "http"
method: "GET"
path: "/users"
timeout: 30000
securityDefinitions:
apig-auth-app:
in: header
name: Authorization
type: apiKey
x-apigateway-auth-type: AppSigv1
apig-auth-iam:
in: header
name: unused
type: apiKey
x-apigateway-auth-type: IAM
OpenAPI示例:
openapi: 3.0.0
info:
description: import apis
title: importHttpVpcEndpoint
version: '1.0'
servers:
- url: >-
http://abc.com
- url: >-
https://abc.com
paths:
/http-vpc:
x-apigateway-any-method:
description: user operation resource
operationId: userOperation
parameters:
- description: authorization signature
example: ''
in: header
name: Authorization
required: true
schema:
maxLength: 0
maximum: 0
minimum: 0
type: string
x-apigateway-pass-through: always
responses:
default-cors:
description: response example
x-apigateway-result-failure-sample: ''
x-apigateway-result-normal-sample: ''
security:
- apig-auth-app: []
servers:
- url: >-
https://abc.com
x-apigateway-backend:
httpVpcEndpoints:
cascade_flag: false
description: ''
enableClientSsl: false
method: GET
name: userVpc
path: /users
retryCount: '-1'
scheme: http
timeout: 30000
parameters:
- description: invoke user
in: HEADER
name: X-Invoke-User
origin: CONSTANT
value: apigateway
type: HTTP-VPC
x-apigateway-cors: true
x-apigateway-is-send-fg-body-base64: true
x-apigateway-match-mode: SWA
x-apigateway-request-type: public
components:
responses:
default-cors:
description: response example
headers:
Access-Control-Allow-Origin:
schema:
default: '*'
type: string
securitySchemes:
apig-auth-app:
in: header
name: Authorization
type: apiKey
x-apigateway-auth-type: AppSigv1
apig-auth-app-header:
in: header
name: Authorization
type: apiKey
x-apigateway-auth-opt:
appcode-auth-type: header
x-apigateway-auth-type: AppSigv1
apig-auth-iam:
in: header
name: unused
type: apiKey
x-apigateway-auth-type: IAM
x-apigateway-responses: {} 导入FUNCTION类型后端服务API示例
包含IAM认证和请求参数编排的GET方法API定义,后端服务类型为FunctionGraph。
Swagger示例:
swagger: "2.0"
info:
title: "importFunctionEndpoint"
description: "import apis"
version: "1.0"
host: "api.account.com"
paths:
'/function/{name}':
get:
operationId: "invokeFunction"
description: "invoke function by name"
security:
- apig-auth-iam: []
schemes:
- https
parameters:
- name: "test"
description: "authorization token"
type: "string"
in: "header"
required: true
- name: "name"
description: "function name"
type: "string"
in: "path"
required: true
responses:
"200":
description: "function result"
x-apigateway-request-type: "public"
x-apigateway-cors: true
x-apigateway-is-send-fg-body-base64: true
x-apigateway-match-mode: "NORMAL"
x-apigateway-backend:
type: "FUNCTION"
parameters:
- name: "functionName"
value: "name"
in: "query"
origin: "REQUEST"
description: "function name"
- name: "X-Invoke-User"
value: "apigateway"
in: "header"
origin: "CONSTANT"
description: "invoke user"
functionEndpoints:
function-urn: "your function urn address"
version: "your function version"
invocation-type: "async"
timeout: 30000
securityDefinitions:
apig-auth-app:
in: header
name: Authorization
type: apiKey
x-apigateway-auth-type: AppSigv1
apig-auth-iam:
in: header
name: unused
type: apiKey
x-apigateway-auth-type: IAM
OpenAPI示例:
openapi: 3.0.0
info:
description: import apis
title: importHttpEndpoint
version: '1.0'
servers:
- url: >-
http://api.account.com
- url: >-
https://api.account.com
paths:
/function/{name}:
get:
description: invoke function by name
operationId: invokeFunction
parameters:
- description: function name
in: path
name: name
required: true
schema:
maxLength: 0
maximum: 0
minimum: 0
type: string
x-apigateway-pass-through: always
example: ''
- description: authorization token
in: header
name: test
required: true
schema:
maxLength: 0
maximum: 0
minimum: 0
type: string
x-apigateway-pass-through: always
example: ''
responses:
default-cors:
description: response example
x-apigateway-result-failure-sample: ''
x-apigateway-result-normal-sample: ''
security:
- apig-auth-iam: []
servers:
- url: >-
https://api.account.com
x-apigateway-backend:
functionEndpoints:
alias-urn: ''
description: ''
function-urn: "your function urn address"
invocation-type: async
network-type: V1
timeout: 30000
version: "your function version"
parameters:
- description: invoke user
in: HEADER
name: X-Invoke-User
origin: CONSTANT
value: apigateway
- description: function name
in: QUERY
name: functionName
origin: REQUEST
value: name
type: FUNCTION
x-apigateway-cors: true
x-apigateway-is-send-fg-body-base64: true
x-apigateway-match-mode: NORMAL
x-apigateway-request-type: public
x-apigateway-response: default
components:
responses:
default-cors:
description: response example
headers:
Access-Control-Allow-Origin:
schema:
default: '*'
type: string
securitySchemes:
apig-auth-app:
in: header
name: Authorization
type: apiKey
x-apigateway-auth-type: AppSigv1
apig-auth-iam:
in: header
name: unused
type: apiKey
x-apigateway-auth-type: IAM
x-apigateway-responses:
default: {} 导入MOCK类型后端服务API示例
包含无认证的GET方法API定义,后端服务类型为MOCK。
Swagger示例:
swagger: "2.0"
info:
title: "importMockEndpoint"
description: "import apis"
version: "1.0"
host: "api.account.com"
paths:
'/mock':
get:
operationId: "mock"
description: "mock test"
schemes:
- http
responses:
"200":
description: "mock result"
x-apigateway-request-type: "private"
x-apigateway-cors: true
x-apigateway-is-send-fg-body-base64: true
x-apigateway-match-mode: "NORMAL"
x-apigateway-backend:
type: "MOCK"
mockEndpoints:
result-content: "{\"message\": \"mocked\"}"
securityDefinitions:
apig-auth-app:
in: header
name: Authorization
type: apiKey
x-apigateway-auth-type: AppSigv1
apig-auth-iam:
in: header
name: unused
type: apiKey
x-apigateway-auth-type: IAM
OpenAPI示例:
openapi: 3.0.0
info:
description: import apis
title: importHttpVpcEndpoint
version: '1.0'
servers:
- url: >-
http://abc.com
- url: >-
https://abc.com
paths:
/mock:
get:
description: mock test
operationId: mock
responses:
default-cors:
description: response example
x-apigateway-result-failure-sample: ''
x-apigateway-result-normal-sample: ''
servers:
- url: >-
http://abc.com
x-apigateway-backend:
mockEndpoints:
description: ''
result-content: '{"message": "mocked"}'
type: MOCK
x-apigateway-cors: true
x-apigateway-is-send-fg-body-base64: true
x-apigateway-match-mode: NORMAL
x-apigateway-request-type: private
x-apigateway-response: default
components:
responses:
default-cors:
description: response example
headers:
Access-Control-Allow-Origin:
schema:
default: '*'
type: string
securitySchemes:
apig-auth-app:
in: header
name: Authorization
type: apiKey
x-apigateway-auth-type: AppSigv1
apig-auth-app-header:
in: header
name: Authorization
type: apiKey
x-apigateway-auth-opt:
appcode-auth-type: header
x-apigateway-auth-type: AppSigv1
apig-auth-iam:
in: header
name: unused
type: apiKey
x-apigateway-auth-type: IAM
x-apigateway-responses:
default: {}