Exporting an HTTP API from API Gateway - Amazon API Gateway

Exporting an HTTP API from API Gateway

After you've created an HTTP API, you can export an OpenAPI 3.0 definition of your API from API Gateway. You can either choose a stage to export, or export the latest configuration of your API. You can also import an exported API definition into API Gateway to create another, identical API. To learn more about importing API definitions, see Importing an HTTP API.

Export an OpenAPI 3.0 definition of a stage by using the AWS CLI

The following command exports an OpenAPI definition of an API stage named prod to a YAML file named stage-definition.yaml. The exported definition file includes API Gateway extensions by default.

aws apigatewayv2 export-api \ --api-id api-id \ --output-type YAML \ --specification OAS30 \ --stage-name prod \ stage-definition.yaml

Export an OpenAPI 3.0 definition of your API's latest changes by using the AWS CLI

The following command exports an OpenAPI definition of an HTTP API to a JSON file named latest-api-definition.json. Because the command doesn't specify a stage, API Gateway exports the latest configuration of your API, whether it has been deployed to a stage or not. The exported definition file doesn't include API Gateway extensions.

aws apigatewayv2 export-api \ --api-id api-id \ --output-type JSON \ --specification OAS30 \ --no-include-extensions \ latest-api-definition.json

For more information, see ExportAPI in the Amazon API Gateway Version 2 API Reference.

Export an OpenAPI 3.0 definition by using the API Gateway console

The following procedure shows how to export an OpenAPI definition of an HTTP API.

To export an OpenAPI 3.0 definition using the API Gateway console
  1. Sign in to the API Gateway console at https://console.aws.amazon.com/apigateway.

  2. Choose an HTTP API.

  3. On the main navigation pane, under Develop, choose Export.

  4. Select from the following options to export your API:

    
          Export options for HTTP APIs.
    1. For Source, select a source for the OpenAPI 3.0 definition. You can choose a stage to export, or export the latest configuration of your API.

    2. Turn on Include API Gateway extensions to include API Gateway extensions.

    3. For Output format, select an output format.

  5. Choose Download.