tencent cloud

Feedback

ImportOpenApi

Last updated: 2024-10-10 21:40:57

    1. API Description

    Domain name for API request: apigateway.tencentcloudapi.com.

    This API is used to import an OpenAPI to API gateway.

    A maximum of 20 requests can be initiated per second for this API.

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

    Parameter Name Required Type Description
    Action Yes String Common Params. The value used for this API: ImportOpenApi.
    Version Yes String Common Params. The value used for this API: 2018-08-08.
    Region Yes String Common Params. For more information, please see the list of regions supported by the product.
    ServiceId Yes String The unique ID of the service associated with the API
    Content Yes String Content of the openAPI
    EncodeType No String Format of the content. Values: YAML (default), JSON
    ContentVersion No String Version of the content. It can only be openAPI for now.

    3. Output Parameters

    Parameter Name Type Description
    Result CreateApiRspSet The result of importing the OpenAPI
    RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

    4. Example

    Example1 ImportOpenApi

    Input Example

    POST / HTTP/1.1
    Host: apigateway.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: ImportOpenApi
    <Common request parameters>
    
    {
        "ServiceId": "service-xxxxx",
        "EncodeType": "YAML",
        "Content": "info:\n  title:test\n  version: 1.0.1\nopenapi: 3.0.0\npaths:\n  /:\n    get:\n      operationId: test\n      responses:\n        '200':\n          description: The list of possible responsesas they are returned from executing\n            this operation.\n      x-apigw-api-business-type: NORMAL\n      x-apigw-api-type: NORMAL\n      x-apigw-backend:\n        MockReturnHttpHeaders: []\n        MockReturnHttpStatusCode: 200\n        ServiceMockReturnMessage: ok\n        ServiceType: MOCK\n      x-apigw-cors: false\n      x-apigw-protocol: HTTP\n      x-apigw-service-timeout: 15\n",
        "ContentVersion": "openAPI"
    }
    

    Output Example

    {
        "Response": {
            "Result": {
                "TotalCount": 1,
                "ApiSet": [
                    {
                        "ApiName": "test",
                        "Path": "/",
                        "Method": "GET",
                        "Status": "success",
                        "ErrMsg": "",
                        "ApiId": "api-xxxxxxx",
                        "CreatedTime": "2020-09-22T00:00:00+00:00"
                    }
                ]
            },
            "RequestId": "61cb6d76-xxxx-xxxx-xxx-xxxxxxxxxx"
        }
    }
    

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    AuthFailure Error with CAM signature/authentication.
    FailedOperation.ApiError API error.
    InternalError Internal error.
    InternalError.OssException OSS internal request error. Please try again. If the problem persists, please contact the smart customer service or submit a ticket.
    InvalidParameter.FormatError Incorrect parameter format.
    InvalidParameterValue The parameter value is incorrect.
    InvalidParameterValue.InvalidServiceConfig Invalid service configuration.
    InvalidParameterValue.UnsupportedParameter Invalid parameter value.
    LimitExceeded.ApiCountLimitExceeded The number of APIs exceeds the limit.
    MissingParameter.BackendSpecificParam The backend service parameter is missing.
    ResourceNotFound The resource does not exist.
    UnauthorizedOperation.AccessResource You do not have permission to access the resource.
    UnsupportedOperation.InvalidAction API error.
    UnsupportedOperation.UnpackError