exportApi method
May throw NotFoundException. May throw TooManyRequestsException. May throw BadRequestException.
Parameter apiId
:
The API identifier.
Parameter outputType
:
The output type of the exported definition file. Valid values are JSON and
YAML.
Parameter specification
:
The version of the API specification to use. OAS30, for OpenAPI 3.0, is
the only supported value.
Parameter exportVersion
:
The version of the API Gateway export algorithm. API Gateway uses the
latest version by default. Currently, the only supported version is 1.0.
Parameter includeExtensions
:
Specifies whether to include API
Gateway extensions in the exported API definition. API Gateway
extensions are included by default.
Parameter stageName
:
The name of the API stage to export. If you don't specify this property, a
representation of the latest API configuration is exported.
Implementation
Future<ExportApiResponse> exportApi({
required String apiId,
required String outputType,
required String specification,
String? exportVersion,
bool? includeExtensions,
String? stageName,
}) async {
ArgumentError.checkNotNull(apiId, 'apiId');
ArgumentError.checkNotNull(outputType, 'outputType');
ArgumentError.checkNotNull(specification, 'specification');
final $query = <String, List<String>>{
'outputType': [outputType],
if (exportVersion != null) 'exportVersion': [exportVersion],
if (includeExtensions != null)
'includeExtensions': [includeExtensions.toString()],
if (stageName != null) 'stageName': [stageName],
};
final response = await _protocol.sendRaw(
payload: null,
method: 'GET',
requestUri:
'/v2/apis/${Uri.encodeComponent(apiId)}/exports/${Uri.encodeComponent(specification)}',
queryParams: $query,
exceptionFnMap: _exceptionFns,
);
return ExportApiResponse(
body: await response.stream.toBytes(),
);
}