All Products
Search
Document Center

API Gateway:ImportOAS

Last Updated:Jul 31, 2025

Imports OpenAPI Specification (OAS)-compliant data to create an API.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • For mandatory resource types, indicate with a prefix of * .
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
apigateway:ImportOAScreate
*ApiGroup
acs:apigateway:{#regionId}:{#accountId}:apigroup/{#GroupId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
GroupIdstringYes

The ID of the API group.

08ae4aa0f95e4321849ee57f4e0b3077
DatastringYes

The OAS-compliant text file or OSS object URL.

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"
OverwritebooleanYes

Specifies whether to overwrite an existing API.

If an existing API has the same HTTP request type and backend request path as the API to be imported, the existing API is overwritten.

true
IgnoreWarningbooleanNo

Specifies whether to ignore alerts.

true
SkipDryRunbooleanNo

Specifies whether to directly import the API without performing a precheck.

true
OASVersionstringNo

The OAS version.

OAS2
BackendNamestringNo

The name of the backend service.

testBackendService
AuthTypestringNo

The security authentication method of the API. Valid values:

  • APP: Only authorized applications can call the API.

  • ANONYMOUS: The API can be anonymously called. In this mode, you must take note of the following rules:

    • All users who have obtained the API service information can call this API. API Gateway does not authenticate callers and cannot set user-specific throttling policies. If you make this API public, set API-specific throttling policies.
APP
RequestModestringNo

The request mode. Valid values:

  • MAPPING: Parameters are mapped. Unknown parameters are filtered out.
  • PASSTHROUGH: Parameters are passed through.
PASSTHROUGH

Response parameters

ParameterTypeDescriptionExample
object
OperationIdstring

The ID of the asynchronous API import task that was generated during the import operation. This ID is used to query the execution status of the API import task.

c16a1880f5164d779f6a54f64d997cd9
RequestIdstring

The ID of the request.

E7FE7172-AA75-5880-B6F7-C00893E9BC06
ErrorMessagesarray

The error messages that appear due to the invalid data in the imported file.

ErrorMessagestring

The error message that appears due to the invalid data in the imported file.

Invalid extensions:x-aliyun-apigateway-auth-type. Option value [ANONYMOUS, APP].
WarningMessagesarray

The warning messages that appear due to the invalid data in the imported file.

WarningMessagestring

The warning message that appears due to the invalid data in the imported file.

There is no valid api definition in your file.
SuccessApisarray<object>

The information about the APIs that have passed the precheck.

SuccessApiobject

The information about the API that has passed the precheck.

Pathstring

The request path configured when you created the API.

/st1
HttpMethodstring

The HTTP method configured when you created the API.

POST
ApiIdstring

The ID of the API.

92af1abffc2443eaa2b815fdbd9c13f1
ApiOperationstring

Indicates that the operation is CREATE or MODIFY.

CREATE
FailedApisarray<object>

The APIs that failed to pass the precheck.

FailedApiobject

The API that failed to be pass the precheck.

Pathstring

The request path configured when you created the API.

/st1
HttpMethodstring

The HTTP method configured when you created the API.

POST
ErrorMsgstring

The error message.

Invalid Api Definition.
FailedModelsarray<object>

The information about the models that failed to pass the precheck.

FailedModelobject

The information about the model that failed to pass the precheck.

ErrorMsgstring

The error message.

Invalid Model Definition.
ModelNamestring

The name of the model.

test
GroupIdstring

The ID of the API group.

2c1bc62e19614cc68c6b0b484bc9c5db
SuccessModelsarray<object>

The information about the models that have passed the precheck.

SuccessModelobject

The information about the model that has passed the precheck.

ModelUidstring

The UID of the model.

1r4efwee19614cc68c6b0b484bc9c5dbs
ModelNamestring

The name of the model.

test
GroupIdstring

The ID of the API group.

feaccf67040643bcbdedb253e59eb527
ModelOperationstring

The operation of the model. Valid values: CREATE and MODIFY.

CREATE

Examples

Sample success responses

JSONformat

{
  "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"
      }
    ]
  }
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2022-11-16Add OperationView Change Details