aws-cdk-lib.aws_apigateway.RequestValidator

class RequestValidator (construct)

LanguageType name
.NETAmazon.CDK.AWS.APIGateway.RequestValidator
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#RequestValidator
Javasoftware.amazon.awscdk.services.apigateway.RequestValidator
Pythonaws_cdk.aws_apigateway.RequestValidator
TypeScript (source)aws-cdk-lib » aws_apigateway » RequestValidator

Implements IConstruct, IDependable, IResource, IRequestValidator

Example

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_apigateway as apigateway } from 'aws-cdk-lib';

declare const restApi: apigateway.RestApi;
const requestValidator = new apigateway.RequestValidator(this, 'MyRequestValidator', {
  restApi: restApi,

  // the properties below are optional
  requestValidatorName: 'requestValidatorName',
  validateRequestBody: false,
  validateRequestParameters: false,
});

Initializer

new RequestValidator(scope: Construct, id: string, props: RequestValidatorProps)

Parameters

  • scope Construct
  • id string
  • props RequestValidatorProps

Construct Props

NameTypeDescription
restApiIRestApiThe rest API that this model is part of.
requestValidatorName?stringThe name of this request validator.
validateRequestBody?booleanIndicates whether to validate the request body according to the configured schema for the targeted API and method.
validateRequestParameters?booleanIndicates whether to validate request parameters.

restApi

Type: IRestApi

The rest API that this model is part of.

The reason we need the RestApi object itself and not just the ID is because the model is being tracked by the top-level RestApi object for the purpose of calculating it's hash to determine the ID of the deployment. This allows us to automatically update the deployment when the model of the REST API changes.


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.

Properties

NameTypeDescription
envResourceEnvironmentThe environment this resource belongs to.
nodeNodeThe tree node.
requestValidatorIdstringID of the request validator, such as abc123.
stackStackThe stack in which this resource is defined.

env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


node

Type: Node

The tree node.


requestValidatorId

Type: string

ID of the request validator, such as abc123.


stack

Type: Stack

The stack in which this resource is defined.

Methods

NameDescription
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
toString()Returns a string representation of this construct.
static fromRequestValidatorId(scope, id, requestValidatorId)

applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


static fromRequestValidatorId(scope, id, requestValidatorId)

public static fromRequestValidatorId(scope: Construct, id: string, requestValidatorId: string): IRequestValidator

Parameters

  • scope Construct
  • id string
  • requestValidatorId string

Returns

  • IRequestValidator