使用标准OAS定义导入API。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
授权信息
下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:
- 操作:是指具体的权限点。
- 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。
- 资源类型:是指操作中支持授权的资源类型。具体说明如下:- 对于必选的资源类型,用前面加 * 表示。
- 对于不支持资源级授权的操作,用全部资源表示。
 
- 条件关键字:是指云产品自身定义的条件关键字。
- 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。
| 操作 | 访问级别 | 资源类型 | 条件关键字 | 关联操作 | 
|---|---|---|---|---|
| apigateway:ImportOAS | create | *ApiGroup acs:apigateway:{#regionId}:{#accountId}:apigroup/{#GroupId} | 
 | 无 | 
请求参数
| 名称 | 类型 | 必填 | 描述 | 示例值 | 
|---|---|---|---|---|
| GroupId | string | 是 | API 分组的 ID | 08ae4aa0f95e4321849ee57f4e0b3077 | 
| Data | string | 是 | OAS 文本内容,或 OSS 链接 | swagger: "2.0" info: version: "1.0.0" title: "Swagger Petstore 2.0" basePath: "/" schemes: - "https" - "http" paths: /pet/findByStatus: get: tags: - "pet" summary: "Finds Pets by status" operationId: "findPetsByStatus" parameters: - name: "status" in: "query" required: true type: "array" items: type: "string" enum: - "available" - "pending" - "sold" default: "available" collectionFormat: "multi" responses: "200": description: "successful operation" schema: type: "array" items: $ref: "#/definitions/Pet" "400": description: "Invalid status value" definitions: Category: type: "object" properties: id: type: "integer" format: "int64" name: type: "string" Tag: type: "object" properties: id: type: "integer" format: "int64" name: type: "string" Pet: type: "object" required: - "name" - "photoUrls" properties: id: type: "integer" format: "int64" category: $ref: "#/definitions/Category" name: type: "string" example: "doggie" photoUrls: type: "array" items: type: "string" tags: type: "array" items: $ref: "#/definitions/Tag" status: type: "string" description: "pet status in the store" enum: - "available" - "pending" - "sold" | 
| Overwrite | boolean | 是 | 是否覆盖现有 API。 覆盖检测条件为:API 的 HTTP 请求类型+后端请求路径相同。 | true | 
| IgnoreWarning | boolean | 否 | 忽略警告信息 | true | 
| SkipDryRun | boolean | 否 | 跳过预检查,进行导入 | true | 
| OASVersion | string | 否 | OAS 版本信息 | OAS2 | 
| BackendName | string | 否 | 后端服务名称 | testBackendService | 
| AuthType | string | 否 | API 安全认证类型,目前可以取值: 
 | APP | 
| RequestMode | string | 否 | 入参请求的模式,取值为: 
 | PASSTHROUGH | 
返回参数
示例
正常返回示例
JSON格式
{
  "OperationId": "c16a1880f5164d779f6a54f64d997cd9",
  "RequestId": "E7FE7172-AA75-5880-B6F7-C00893E9BC06",
  "ErrorMessages": {
    "ErrorMessage": [
      "Invalid extensions:x-aliyun-apigateway-auth-type. Option value [ANONYMOUS, APP]."
    ]
  },
  "WarningMessages": {
    "WarningMessage": [
      "There is no valid api definition in your file."
    ]
  },
  "SuccessApis": {
    "SuccessApi": [
      {
        "Path": "/st1",
        "HttpMethod": "POST",
        "ApiId": "92af1abffc2443eaa2b815fdbd9c13f1",
        "ApiOperation": "CREATE"
      }
    ]
  },
  "FailedApis": {
    "FailedApi": [
      {
        "Path": "/st1",
        "HttpMethod": "POST",
        "ErrorMsg": "Invalid Api Definition."
      }
    ]
  },
  "FailedModels": {
    "FailedModel": [
      {
        "ErrorMsg": "Invalid Model Definition.",
        "ModelName": "test",
        "GroupId": "2c1bc62e19614cc68c6b0b484bc9c5db"
      }
    ]
  },
  "SuccessModels": {
    "SuccessModel": [
      {
        "ModelUid": "1r4efwee19614cc68c6b0b484bc9c5dbs",
        "ModelName": "test",
        "GroupId": "feaccf67040643bcbdedb253e59eb527",
        "ModelOperation": "CREATE"
      }
    ]
  }
}错误码
访问错误中心查看更多错误码。
变更历史
| 变更时间 | 变更内容概要 | 操作 | 
|---|---|---|
| 2022-11-16 | 新增 OpenAPI | 查看变更详情 | 
