本文介绍不同 API 后端导入 API 示例。YAML 格式示例如下。
后端为 Mock 类型
openapi: 3.0.0info:title: testversion: 1.0.1paths:/:get:operationId: testresponses:'200':description: The list of possible responsesas they are returned from executingthis operation.x-apigw-api-business-type: NORMALx-apigw-api-type: NORMALx-apigw-backend:MockReturnHttpHeaders: []MockReturnHttpStatusCode: 200ServiceMockReturnMessage: successServiceType: MOCKx-apigw-cors: falsex-apigw-protocol: HTTPx-apigw-service-timeout: 15
后端为 Proxy 类型
openapi: 3.0.0info:title: testaversion: 1.0.1paths:/proxy:get:operationId: testresponses:'200':description: The list of possible responsesas they are returned from executingthis operation.x-apigw-api-business-type: NORMALx-apigw-api-type: NORMALx-apigw-backend:ServiceConfig:Method: GETPath: /Url: http://cloud.tencent.comServiceType: HTTPx-apigw-cors: falsex-apigw-protocol: HTTPx-apigw-service-timeout: 15
后端为 VPC 内网服务类型
openapi: 3.0.0info:title: testversion: 1.0.1paths:/:get:operationId: testresponses:'200':description: The list of possible responsesas they are returned from executingthis operation.x-apigw-api-business-type: NORMALx-apigw-api-type: NORMALx-apigw-backend:ServiceConfig:Method: GETPath: /Product: clbUniqVpcId: vpc-xxxxxxUrl: http://172.x.x.x:8xxxServiceType: HTTPx-apigw-const-paramters:- DefaultValue: xxxDesc: "xxxx后端Host"Name: HostPosition: HEADERx-apigw-cors: falsex-apigw-protocol: HTTPx-apigw-service-timeout: 15
后端为 SCF Event 类型
openapi: 3.0.0info:title: testaversion: 1.0.1paths:/scf:get:operationId: testresponses:'200':description: The list of possible responsesas they are returned from executingthis operation.x-apigw-api-business-type: NORMALx-apigw-api-type: NORMALx-apigw-backend:IsBase64Encoded: falseServiceScfFunctionName: APIGWCustomRespDemo-xxxxxServiceScfFunctionNamespace: defaultServiceScfFunctionQualifier: $DEFAULTServiceScfFunctionType: EVENTServiceScfIsIntegratedResponse: falseServiceType: SCFx-apigw-cors: falsex-apigw-protocol: HTTPx-apigw-service-timeout: 15
后端为 SCF Web 函数类型
openapi: 3.0.0info:title: testaversion: 1.0.1paths:/scf:get:operationId: testresponses:'200':description: The list of possible responsesas they are returned from executingthis operation.x-apigw-api-business-type: NORMALx-apigw-api-type: NORMALx-apigw-backend:IsBase64Encoded: falseServiceScfFunctionName: flask_demo-xxxxxxxxxServiceScfFunctionNamespace: defaultServiceScfFunctionQualifier: $DEFAULTServiceScfFunctionType: HTTPServiceScfIsIntegratedResponse: falseServiceType: SCFx-apigw-cors: falsex-apigw-protocol: HTTPx-apigw-service-timeout: 15
后端为 COS 类型
openapi: 3.0.0info:title: testversion: 1.0.1paths:/cos:get:operationId: testresponses:'200':description: The list of possible responsesas they are returned from executingthis operation.x-apigw-api-business-type: NORMALx-apigw-api-type: NORMALx-apigw-backend:ServiceConfig:CosConfig:Action: GetObjectAuthorization: trueBucketName: xxxxxxxPathMatchMode: FullPathPath: /ServiceType: COSx-apigw-cors: falsex-apigw-protocol: HTTPx-apigw-service-timeout: 15
TSF 微服务 API 类型
openapi: 3.0.0info:title: SCF_API_SERVICEversion: 1.0.1paths:/:get:operationId: testparameters:- description: ""in: headername: X-MicroService-Namerequired: trueschema:type: string- description: ""in: headername: X-NameSpace-Coderequired: trueschema:type: stringresponses:'200':description: The list of possible responsesas they are returned from executingthis operation.x-apigw-api-business-type: NORMALx-apigw-api-type: TSFx-apigw-backend:MicroServices:- ClusterId: cluster-xxxxxxMicroServiceName: provider-demoNamespaceId: namespace-xxxxxServiceConfig:Path: /ServiceTsfHealthCheckConf:ErrorThresholdPercentage: 50IsHealthCheck: trueRequestVolumeThreshold: 20SleepWindowInMilliseconds: 5000ServiceTsfLoadBalanceConf:IsLoadBalance: trueMethod: RoundRobinRuleSessionStickRequired: falseSessionStickTimeout: 0ServiceType: TSFx-apigw-cors: falsex-apigw-protocol: HTTPx-apigw-service-timeout: 15
JSON 格式导入 API
以 Mock 后端为例,JSON 格式参考如下。其余类型可参考 YAML 格式。另外,导入数据中如有 x-apigw-backend 则不需要 servers。
info:title: TESTversion: 1.0.1openapi: 3.0.0paths:/mock:get:description: importMockAPIoperationId: Mock APIresponses:'200':description: >-The list of possible responsesas they are returned from executingthis operation.x-apigw-api-business-type: NORMALx-apigw-api-type: NORMALx-apigw-backend:MockReturnHttpHeaders: []MockReturnHttpStatusCode: 200ServiceMockReturnMessage: Import Mock API TestServiceType: MOCKx-apigw-cors: falsex-apigw-protocol: HTTPx-apigw-service-timeout: 15