导入API 导入到已有分组注意事项 将API定义导入到一个已有的分组,导入过程中不会删除分组中已有的API,只是将新增的API导入分组。 适用于将一个新的API或者一个修改后的API导入到已有的分组。 导入API前,请注意以下事项: API网关中API的配额满足需求。 导入的API定义与已有的API定义冲突时,您可以选择使用导入的API定义覆盖已有的API定义,或者保留已有的API定义,此时导入的API定义会显示导入失败。 如果选择扩展覆盖,当导入API的扩展定义项名称与已有策略(ACL,流量控制等)名称相同时,则会覆盖已有策略(ACL,流量控制等)。 导入的API不会自动发布到环境,导入时可以选择“立即发布”或者“稍后发布”,您可以自行选择策略。 操作步骤 步骤 1 进入API网关控制台页面。 步骤 2 根据实际业务在左侧导航栏上方选择实例。 步骤 3 在左侧导航栏选择“API管理 > API列表”。 步骤 4 单击导入API。 您也可以参考以下示例导入API到API网关: 导入HTTP类型后端服务API示例 导入HTTP VPC类型后端服务API示例 导入MOCK类型后端服务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: apigauthiam: [] 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" xapigatewayrequesttype: "public" xapigatewaycors: true xapigatewaymatchmode: "NORMAL" xapigatewaybackend: type: "HTTP" parameters: name: "userId" value: "userId" in: "query" origin: "REQUEST" description: "user id" name: "XInvokeUser" value: "apigateway" in: "header" origin: "CONSTANT" description: "invoke user" httpEndpoints: address: "example.com" scheme: "http" method: "GET" path: "/users" timeout: 30000 securityDefinitions: apigauthapp: in: header name: Authorization type: apiKey xapigatewayauthtype: AppSigv1 apigauthiam: in: header name: unused type: apiKey xapigatewayauthtype: IAM OpenAPI示例: openapi: 3.0.0 info: title: importHttpEndpoint10 version: '1.0' servers: url: > url: > 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 xapigatewaypassthrough: always description: user id example: '' in: path name: userId required: true schema: maxLength: 0 maximum: 0 minimum: 0 type: string xapigatewaypassthrough: always responses: defaultcors: description: response example xapigatewayresultfailuresample: '' xapigatewayresultnormalsample: '' security: apigauthiam: [] servers: url: > xapigatewaybackend: httpEndpoints: address: example.com description: '' enableClientSsl: false method: GET path: /users retryCount: '1' scheme: http timeout: 30000 parameters: description: invoke user in: HEADER name: XInvokeUser origin: CONSTANT value: apigateway description: user id in: QUERY name: userId origin: REQUEST value: userId type: HTTP xapigatewaycors: true xapigatewaymatchmode: NORMAL xapigatewayrequesttype: public xapigatewayresponse: default components: responses: defaultcors: description: response example headers: AccessControlAllowOrigin: schema: default: '' type: string securitySchemes: apigauthapp: in: header name: Authorization type: apiKey xapigatewayauthtype: AppSigv1 apigauthappheader: in: header name: Authorization type: apiKey xapigatewayauthopt: appcodeauthtype: header xapigatewayauthtype: AppSigv1 apigauthiam: in: header name: unused type: apiKey xapigatewayauthtype: IAM xapigatewayresponses: default: {}