createRequestValidator method
Creates a ReqeustValidator of a given RestApi.
May throw BadRequestException. May throw UnauthorizedException. May throw NotFoundException. May throw LimitExceededException. May throw TooManyRequestsException.
Parameter restApiId
:
Required
The string identifier of the associated RestApi.
Parameter name
:
The name of the to-be-created RequestValidator.
Parameter validateRequestBody
:
A Boolean flag to indicate whether to validate request body according to
the configured model schema for the method (true
) or not
(false
).
Parameter validateRequestParameters
:
A Boolean flag to indicate whether to validate request parameters,
true
, or not false
.
Implementation
Future<RequestValidator> createRequestValidator({
required String restApiId,
String? name,
bool? validateRequestBody,
bool? validateRequestParameters,
}) async {
ArgumentError.checkNotNull(restApiId, 'restApiId');
final $payload = <String, dynamic>{
if (name != null) 'name': name,
if (validateRequestBody != null)
'validateRequestBody': validateRequestBody,
if (validateRequestParameters != null)
'validateRequestParameters': validateRequestParameters,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri:
'/restapis/${Uri.encodeComponent(restApiId)}/requestvalidators',
exceptionFnMap: _exceptionFns,
);
return RequestValidator.fromJson(response);
}