RequestValidatorOptions
- class aws_cdk.aws_apigateway.RequestValidatorOptions(*, request_validator_name=None, validate_request_body=None, validate_request_parameters=None)
Bases:
object
- Parameters:
request_validator_name (
Optional
[str
]) – The name of this request validator. Default: Nonevalidate_request_body (
Optional
[bool
]) – Indicates whether to validate the request body according to the configured schema for the targeted API and method. Default: falsevalidate_request_parameters (
Optional
[bool
]) – Indicates whether to validate request parameters. Default: false
- ExampleMetadata:
infused
Example:
# integration: apigateway.LambdaIntegration # resource: apigateway.Resource # response_model: apigateway.Model # error_response_model: apigateway.Model resource.add_method("GET", integration, # We can mark the parameters as required request_parameters={ "method.request.querystring.who": True }, # we can set request validator options like below request_validator_options=apigateway.RequestValidatorOptions( request_validator_name="test-validator", validate_request_body=True, validate_request_parameters=False ), method_responses=[apigateway.MethodResponse( # Successful response from the integration status_code="200", # Define what parameters are allowed or not response_parameters={ "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 response_models={ "application/json": response_model } ), apigateway.MethodResponse( # Same thing for the error responses status_code="400", response_parameters={ "method.response.header.Content-Type": True, "method.response.header.Access-Control-Allow-Origin": True, "method.response.header.Access-Control-Allow-Credentials": True }, response_models={ "application/json": error_response_model } ) ] )
Attributes
- request_validator_name
The name of this request validator.
- Default:
None
- validate_request_body
Indicates whether to validate the request body according to the configured schema for the targeted API and method.
- Default:
false
- validate_request_parameters
Indicates whether to validate request parameters.
- Default:
false