Updated on 2022-09-26 GMT+08:00

Importing APIs

Scenario

API Gateway allows you to import Swagger 2.0 APIs to existing or new API groups. Swagger is an open-source tool built based on OpenAPI specifications to design, build, record, and use REST APIs.

You can import APIs individually or in batches depending on the number of APIs contained in a Swagger file.

Prerequisites

  • The API Swagger file to be imported is available and already has extended API definitions supplemented. For more information, see "Extended Definition" in the Developer Guide.
  • You have sufficient quotas of API groups and APIs.

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner and choose API Gateway.
  3. In the navigation pane, choose Dedicated Gateways. Then click Access Console in the upper right corner of a dedicated gateway.
  4. In the navigation pane, choose API Publishing > APIs.
  5. Click Import API.
  6. Set the parameters listed in Table 1.

    Figure 1 Importing APIs
    Table 1 Parameters for importing APIs

    Parameter

    Description

    Import

    Options:

    • New group: Import APIs to a new API group. If you select this option, the system automatically creates an API group and imports the APIs into this group.
    • Existing group: Import APIs to an existing API group. If you select this option, the system adds the APIs to the selected API group while retaining the existing APIs in the API group.

    API group

    Select an API group if you set Import to Existing group.

    Basic Definition Overwrite

    Determine whether to overwrite an existing API if the name of the API is the same as that of an imported API.

    This parameter is available only if you set Import to Existing group.

    Extended Definition Overwrite

    If this option is selected, the extended definition items (access control and request throttling policies) of an imported API will overwrite the existing policies with the same name.

  7. In the Parameter Import area, click File and select a file to import.

    YAML and JSON files are supported. You can preview the API content to be imported on the Import API page.
    Figure 2 Parameter Import

  8. (Optional) Configure global settings for the APIs to be imported.

    You can configure the global settings for the APIs, such as frontend and backend requests, or modify other parameters of the APIs.

  9. Click Import Now to import the APIs.

    Imported APIs must be manually published so that they become available for users to access.

Follow-Up Operations

Publish the imported API in an environment so that it can be called by users.