Table of Contents

Class RequestValidatorOptions

Namespace
Amazon.CDK.AWS.APIGateway
Assembly
Amazon.CDK.AWS.APIGateway.dll
public class RequestValidatorOptions : IRequestValidatorOptions
Inheritance
RequestValidatorOptions
Implements
Inherited Members

Examples

LambdaIntegration integration;
            Resource resource;
            Model responseModel;
            Model errorResponseModel;


            resource.AddMethod("GET", integration, new MethodOptions {
                // We can mark the parameters as required
                RequestParameters = new Dictionary<string, boolean> {
                    { "method.request.querystring.who", true }
                },
                // we can set request validator options like below
                RequestValidatorOptions = new RequestValidatorOptions {
                    RequestValidatorName = "test-validator",
                    ValidateRequestBody = true,
                    ValidateRequestParameters = false
                },
                MethodResponses = new [] { new MethodResponse {
                    // Successful response from the integration
                    StatusCode = "200",
                    // Define what parameters are allowed or not
                    ResponseParameters = new Dictionary<string, boolean> {
                        { "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 = new Dictionary<string, IModel> {
                        { "application/json", responseModel }
                    }
                }, new MethodResponse {
                    // Same thing for the error responses
                    StatusCode = "400",
                    ResponseParameters = new Dictionary<string, boolean> {
                        { "method.response.header.Content-Type", true },
                        { "method.response.header.Access-Control-Allow-Origin", true },
                        { "method.response.header.Access-Control-Allow-Credentials", true }
                    },
                    ResponseModels = new Dictionary<string, IModel> {
                        { "application/json", errorResponseModel }
                    }
                } }
            });

Remarks

ExampleMetadata: infused

Constructors

RequestValidatorOptions()

public RequestValidatorOptions()

Properties

RequestValidatorName

The name of this request validator.

public string? RequestValidatorName { get; set; }

Property Value

string

Remarks

Default: None

ValidateRequestBody

Indicates whether to validate the request body according to the configured schema for the targeted API and method.

public bool? ValidateRequestBody { get; set; }

Property Value

bool?

Remarks

Default: false

ValidateRequestParameters

Indicates whether to validate request parameters.

public bool? ValidateRequestParameters { get; set; }

Property Value

bool?

Remarks

Default: false