Class RequestValidatorOptions
Inheritance
System.Object
RequestValidatorOptions
Implements
Namespace: Amazon.CDK.AWS.APIGateway
Assembly: Amazon.CDK.AWS.APIGateway.dll
Syntax (csharp)
public class RequestValidatorOptions : Object, IRequestValidatorOptions
Syntax (vb)
Public Class RequestValidatorOptions
Inherits Object
Implements IRequestValidatorOptions
Remarks
ExampleMetadata: infused
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 }
}
} }
});
Synopsis
Constructors
RequestValidatorOptions() |
Properties
RequestValidatorName | The name of this request validator. |
ValidateRequestBody | Indicates whether to validate the request body according to the configured schema for the targeted API and method. |
ValidateRequestParameters | Indicates whether to validate request parameters. |
Constructors
RequestValidatorOptions()
public RequestValidatorOptions()
Properties
RequestValidatorName
The name of this request validator.
public string RequestValidatorName { get; set; }
Property Value
System.String
Remarks
Default: None
ValidateRequestBody
Indicates whether to validate the request body according to the configured schema for the targeted API and method.
public Nullable<bool> ValidateRequestBody { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: false
ValidateRequestParameters
Indicates whether to validate request parameters.
public Nullable<bool> ValidateRequestParameters { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: false