Skip to content

Commit bc391ce

Browse files
authored
feat(apigatewayv2): add disableSchemaValidation for Websocket api (#35290)
### Issue # (if applicable) Closes #<issue number here>. ### Reason for this change A property in L1 construct was not in L2 construct. ### Description of changes Add `disableSchemaValidation` property to `WebSocketApiProps` and set in the `CfnApi` constructor. ### Describe any new or updated permissions being added ### Description of how you validated changes Added both unit and integration tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 3384724 commit bc391ce

File tree

11 files changed

+553
-139
lines changed

11 files changed

+553
-139
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2/test/websocket/integ.api.js.snapshot/aws-cdk-aws-apigatewayv2.assets.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2/test/websocket/integ.api.js.snapshot/aws-cdk-aws-apigatewayv2.template.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
"ProtocolType": "WEBSOCKET",
88
"RouteSelectionExpression": "$request.body.action"
99
}
10+
},
11+
"WebSocketApiWithProps9DA8D44F": {
12+
"Type": "AWS::ApiGatewayV2::Api",
13+
"Properties": {
14+
"DisableSchemaValidation": true,
15+
"Name": "WebSocketApiWithProps",
16+
"ProtocolType": "WEBSOCKET",
17+
"RouteSelectionExpression": "$request.body.action"
18+
}
1019
}
1120
},
1221
"Parameters": {

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2/test/websocket/integ.api.js.snapshot/cdk.out

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2/test/websocket/integ.api.js.snapshot/integ.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2/test/websocket/integ.api.js.snapshot/manifest.json

Lines changed: 496 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2/test/websocket/integ.api.js.snapshot/tree.json

Lines changed: 1 addition & 127 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2/test/websocket/integ.api.js.snapshot/websocketapiDefaultTestDeployAssert230DE1C6.assets.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2/test/websocket/integ.api.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ const stack = new cdk.Stack(app, 'aws-cdk-aws-apigatewayv2');
88

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

11+
new apigw.WebSocketApi(stack, 'WebSocketApiWithProps', {
12+
disableSchemaValidation: true,
13+
});
14+
1115
new IntegTest(app, 'web-socket-api', {
1216
testCases: [stack],
1317
});

packages/aws-cdk-lib/aws-apigatewayv2/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,14 @@ const arn = api.arnForExecuteApiV2('$connect', 'dev');
524524

525525
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.
526526

527+
To disable schema validation, set `disableSchemaValidation` to true.
528+
529+
```ts
530+
new apigwv2.WebSocketApi(this, 'api', {
531+
disableSchemaValidation: true,
532+
});
533+
```
534+
527535
You can configure IP address type for the API endpoint using `ipAddressType` property.
528536
Valid values are `IPV4` (default) and `DUAL_STACK`.
529537

packages/aws-cdk-lib/aws-apigatewayv2/lib/websocket/api.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ export interface WebSocketApiProps {
9494
* @default undefined - AWS default is IPV4
9595
*/
9696
readonly ipAddressType?: IpAddressType;
97+
98+
/**
99+
* Avoid validating models when creating a deployment.
100+
*
101+
* @default false
102+
*/
103+
readonly disableSchemaValidation?: boolean;
97104
}
98105

99106
/**
@@ -162,6 +169,7 @@ export class WebSocketApi extends ApiBase implements IWebSocketApi {
162169
description: props?.description,
163170
routeSelectionExpression: props?.routeSelectionExpression ?? '$request.body.action',
164171
ipAddressType: props?.ipAddressType,
172+
disableSchemaValidation: props?.disableSchemaValidation,
165173
});
166174
this.apiId = resource.ref;
167175
this.apiEndpoint = resource.attrApiEndpoint;

0 commit comments

Comments
 (0)