Skip to content

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
"ProtocolType": "WEBSOCKET",
"RouteSelectionExpression": "$request.body.action"
}
},
"WebSocketApiWithProps9DA8D44F": {
"Type": "AWS::ApiGatewayV2::Api",
"Properties": {
"DisableSchemaValidation": true,
"Name": "WebSocketApiWithProps",
"ProtocolType": "WEBSOCKET",
"RouteSelectionExpression": "$request.body.action"
}
}
},
"Parameters": {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const stack = new cdk.Stack(app, 'aws-cdk-aws-apigatewayv2');

new apigw.WebSocketApi(stack, 'WebSocketApi');

new apigw.WebSocketApi(stack, 'WebSocketApiWithProps', {
disableSchemaValidation: true,
});

new IntegTest(app, 'web-socket-api', {
testCases: [stack],
});
Expand Down
8 changes: 8 additions & 0 deletions packages/aws-cdk-lib/aws-apigatewayv2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,14 @@ const arn = api.arnForExecuteApiV2('$connect', 'dev');

For a detailed explanation of this function, including usage and examples, please refer to the [Generating ARN for Execute API](#generating-arn-for-execute-api) section under HTTP API.

To disable schema validation, set `disableSchemaValidation` to true.

```ts
new apigwv2.WebSocketApi(this, 'api', {
disableSchemaValidation: true,
});
```

You can configure IP address type for the API endpoint using `ipAddressType` property.
Valid values are `IPV4` (default) and `DUAL_STACK`.

Expand Down
8 changes: 8 additions & 0 deletions packages/aws-cdk-lib/aws-apigatewayv2/lib/websocket/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ export interface WebSocketApiProps {
* @default undefined - AWS default is IPV4
*/
readonly ipAddressType?: IpAddressType;

/**
* Avoid validating models when creating a deployment.
*
* @default false
*/
readonly disableSchemaValidation?: boolean;
}

/**
Expand Down Expand Up @@ -162,6 +169,7 @@ export class WebSocketApi extends ApiBase implements IWebSocketApi {
description: props?.description,
routeSelectionExpression: props?.routeSelectionExpression ?? '$request.body.action',
ipAddressType: props?.ipAddressType,
disableSchemaValidation: props?.disableSchemaValidation,
});
this.apiId = resource.ref;
this.apiEndpoint = resource.attrApiEndpoint;
Expand Down
15 changes: 15 additions & 0 deletions packages/aws-cdk-lib/aws-apigatewayv2/test/websocket/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,21 @@ describe('WebSocketApi', () => {
IpAddressType: ipAddressType,
});
});

test.each([true, false, undefined])('disableSchemaValidation is set to %s', (disableSchemaValidation) => {
const stack = new Stack();
new WebSocketApi(stack, 'api', {
disableSchemaValidation,
});

const value = disableSchemaValidation !== undefined ? disableSchemaValidation : Match.absent();

Template.fromStack(stack).hasResourceProperties('AWS::ApiGatewayV2::Api', {
Name: 'api',
ProtocolType: 'WEBSOCKET',
DisableSchemaValidation: value,
});
});
});

class DummyIntegration extends WebSocketRouteIntegration {
Expand Down
Loading