Export HTTP APIs 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-typeYAML
\ --specification OAS30 \ --stage-nameprod
\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-typeJSON
\ --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
-
Sign in to the API Gateway console at https://console.aws.amazon.com/apigateway
. -
Choose an HTTP API.
-
On the main navigation pane, under Develop, choose Export.
-
Select from the following options to export your API:
-
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.
-
Turn on Include API Gateway extensions to include API Gateway extensions.
-
For Output format, select an output format.
-
-
Choose Download.