Description
You can call this operation to import a Swagger API from a text string. It supports API configurations that comply with the following specifications:
- Swagger 2.0-based extensions.
- JSON or YAML format.
Request parameters
Name | Type | Required | Description |
---|---|---|---|
Action | String | Yes | You can call this operation to import Swagger APIs. Value: ImportSwagger. |
GroupId | String | Yes | The group number of the imported Swagger. |
Overwrite | Boolean | Yes | Specifies whether to overwrite the existing API. If the imported API has the same HTTP request method and request path as the existing API, the existing API will be overwritten. |
DataFormat | String | Yes | Swagger text format:
|
Data | String | Yes | Swagger text content. For more information, see Import API through Swagger |
Response parameters
Name | Data type | Description |
---|---|---|
RequestId | String | The request number. |
Success | ApiImportSwaggerSuccess | Information about all Swagger-based APIs that have been successfully imported. |
Failed | ApiImportSwaggerFailed | Information about all Swagger-based APIs that have failed to be imported. |
Object description:
ApiImportSwaggerSuccess
Property name | Data type | Description |
---|---|---|
Path | String | The request path that is configured when you create an API. |
Method | String | The configured HTTP method when you create an API. |
ApiUid | String | The successfully imported UID for the API. |
ApiOperation | String | Indicates whether a new API is created or an existing API is updated. |
ApiImportSwaggerFailed
Property name | Data type | Description |
---|---|---|
Path | String | The request path that is configured when you create an API. |
Method | String | The HTTP method that is configured when you create an API. |
ErrorMsg | String | The error message that is returned when you create an API. |
Sample requests
POST /? Action=ImportSwagger
&GroupId=0009db9c828549768a200320714b8930
&Overwrite=true
&DataFormat=yaml
&Data="A Swagger API definition in YAML"
&<Common request parameters>
Sample responses
XML
format
<RequestId>647CEF05-404C-4125-B3D7-44792EB77392</RequestId>
<Failed>
<ApiImportSwaggerFailed>
<ErrorMsg>api already exists: apiUid ===> 8e274ec61cf6468e83b68371956831cb</ErrorMsg>
<HttpMethod>post</HttpMethod>
<Path>/http/get/mapping</Path>
</ApiImportSwaggerFailed>
</Failed>
<Success>
<ApiImportSwaggerSuccess>
<Operation>CREATE</Operation>
<ApiUid>8e274ec61cf6468e83b68371956831cb</ApiUid>
<HttpMethod>get</HttpMethod>
<Path>/http/get/mapping</Path>
</ApiImportSwaggerSuccess>
</Success>
JSON
format
{
"RequestId": "647CEF05-404C-4125-B3D7-44792EB77392",
"Failed": {
"ApiImportSwaggerFailed": [
{
"ErrorMsg": "api already exists : apiUid ===> 8e274ec61cf6468e83b68371956831cb",
"HttpMethod": "post",
"Path": "/http/get/mapping"
}
]
},
"Success": {
"ApiImportSwaggerSuccess": [
{
"Operation": "CREATE",
"ApiUid": "8e274ec61cf6468e83b68371956831cb",
"HttpMethod": "get",
"Path": "/http/get/mapping"
}
]
}
}