interface RequestValidatorOptions
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.APIGateway.RequestValidatorOptions |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#RequestValidatorOptions |
Java | software.amazon.awscdk.services.apigateway.RequestValidatorOptions |
Python | aws_cdk.aws_apigateway.RequestValidatorOptions |
TypeScript (source) | aws-cdk-lib » aws_apigateway » RequestValidatorOptions |
Example
declare const integration: apigateway.LambdaIntegration;
declare const resource: apigateway.Resource;
declare const responseModel: apigateway.Model;
declare const errorResponseModel: apigateway.Model;
resource.addMethod('GET', integration, {
// We can mark the parameters as required
requestParameters: {
'method.request.querystring.who': true
},
// we can set request validator options like below
requestValidatorOptions: {
requestValidatorName: 'test-validator',
validateRequestBody: true,
validateRequestParameters: false
},
methodResponses: [
{
// Successful response from the integration
statusCode: '200',
// Define what parameters are allowed or not
responseParameters: {
'method.response.header.Content-Type': true,
'method.response.header.Access-Control-Allow-Origin': true,
'method.response.header.Access-Control-Allow-Credentials': true
},
// Validate the schema on the response
responseModels: {
'application/json': responseModel
}
},
{
// Same thing for the error responses
statusCode: '400',
responseParameters: {
'method.response.header.Content-Type': true,
'method.response.header.Access-Control-Allow-Origin': true,
'method.response.header.Access-Control-Allow-Credentials': true
},
responseModels: {
'application/json': errorResponseModel
}
}
]
});
Properties
Name | Type | Description |
---|---|---|
request | string | The name of this request validator. |
validate | boolean | Indicates whether to validate the request body according to the configured schema for the targeted API and method. |
validate | boolean | Indicates whether to validate request parameters. |
requestValidatorName?
Type:
string
(optional, default: None)
The name of this request validator.
validateRequestBody?
Type:
boolean
(optional, default: false)
Indicates whether to validate the request body according to the configured schema for the targeted API and method.
validateRequestParameters?
Type:
boolean
(optional, default: false)
Indicates whether to validate request parameters.