getExport method
Exports a deployed version of a RestApi in a specified format.
May throw UnauthorizedException. May throw NotFoundException. May throw BadRequestException. May throw ConflictException. May throw TooManyRequestsException.
Parameter exportType
:
Required
The type of export. Acceptable values are 'oas30' for OpenAPI
3.0.x and 'swagger' for Swagger/OpenAPI 2.0.
Parameter restApiId
:
Required
The string identifier of the associated RestApi.
Parameter stageName
:
Required
The name of the Stage that will be exported.
Parameter accepts
:
The content-type of the export, for example application/json
.
Currently application/json
and application/yaml
are supported for exportType
ofoas30
and
swagger
. This should be specified in the Accept
header for direct API requests.
Parameter parameters
:
A key-value map of query string parameters that specify properties of the
export, depending on the requested exportType
. For
exportType
oas30
and swagger
, any
combination of the following parameters are supported:
extensions='integrations'
or
extensions='apigateway'
will export the API with
x-amazon-apigateway-integration extensions.
extensions='authorizers'
will export the API with
x-amazon-apigateway-authorizer extensions. postman
will
export the API with Postman extensions, allowing for import to the Postman
tool
Implementation
Future<ExportResponse> getExport({
required String exportType,
required String restApiId,
required String stageName,
String? accepts,
Map<String, String>? parameters,
}) async {
ArgumentError.checkNotNull(exportType, 'exportType');
ArgumentError.checkNotNull(restApiId, 'restApiId');
ArgumentError.checkNotNull(stageName, 'stageName');
final headers = <String, String>{
if (accepts != null) 'Accept': accepts.toString(),
};
final $query = <String, List<String>>{
if (parameters != null)
for (var e in parameters.entries) e.key: [e.value],
};
final response = await _protocol.sendRaw(
payload: null,
method: 'GET',
requestUri:
'/restapis/${Uri.encodeComponent(restApiId)}/stages/${Uri.encodeComponent(stageName)}/exports/${Uri.encodeComponent(exportType)}',
queryParams: $query,
headers: headers,
exceptionFnMap: _exceptionFns,
);
return ExportResponse(
body: await response.stream.toBytes(),
contentDisposition:
_s.extractHeaderStringValue(response.headers, 'Content-Disposition'),
contentType:
_s.extractHeaderStringValue(response.headers, 'Content-Type'),
);
}