diff --git a/allowed-breaking-changes.txt b/allowed-breaking-changes.txt index d2569b96e5595..112b15f393e56 100644 --- a/allowed-breaking-changes.txt +++ b/allowed-breaking-changes.txt @@ -957,3 +957,6 @@ weakened:aws-cdk-lib.cx_api.MetadataEntryResult strengthened:aws-cdk-lib.aws_eks.ClusterProps strengthened:aws-cdk-lib.aws_eks.FargateClusterProps removed:aws-cdk-lib.lambda_layer_kubectl.KubectlLayer + +# Fixing the JsonSchema interface to be consistent with JSON Schema spec +changed-type:aws-cdk-lib.aws_apigateway.JsonSchema.additionalItems diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/ModelSchemaAdditionalItemsTestDefaultTestDeployAssert81CF581B.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/ModelSchemaAdditionalItemsTestDefaultTestDeployAssert81CF581B.assets.json new file mode 100644 index 0000000000000..4d1ffdf2bae6a --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/ModelSchemaAdditionalItemsTestDefaultTestDeployAssert81CF581B.assets.json @@ -0,0 +1,19 @@ +{ + "version": "40.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "ModelSchemaAdditionalItemsTestDefaultTestDeployAssert81CF581B.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/ModelSchemaAdditionalItemsTestDefaultTestDeployAssert81CF581B.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/ModelSchemaAdditionalItemsTestDefaultTestDeployAssert81CF581B.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/ModelSchemaAdditionalItemsTestDefaultTestDeployAssert81CF581B.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value<String>", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/cdk.out new file mode 100644 index 0000000000000..1e02a2deb191b --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"40.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/integ.json new file mode 100644 index 0000000000000..c2881ff969bb5 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "40.0.0", + "testCases": { + "ModelSchemaAdditionalItemsTest/DefaultTest": { + "stacks": [ + "model-schema-additional-items-test" + ], + "assertionStack": "ModelSchemaAdditionalItemsTest/DefaultTest/DeployAssert", + "assertionStackName": "ModelSchemaAdditionalItemsTestDefaultTestDeployAssert81CF581B" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/manifest.json new file mode 100644 index 0000000000000..18f5f6cc01500 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/manifest.json @@ -0,0 +1,288 @@ +{ + "version": "40.0.0", + "artifacts": { + "model-schema-additional-items-test.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "model-schema-additional-items-test.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "model-schema-additional-items-test": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "model-schema-additional-items-test.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/b49c1b4daac47f77703412f366f4599fffc5e3f904aaf1dc3bc06abcb953c26e.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "model-schema-additional-items-test.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "model-schema-additional-items-test.assets" + ], + "metadata": { + "/model-schema-additional-items-test/model-schema-api": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "restApiName": "*" + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addModel": [ + "*", + { + "contentType": "*", + "modelName": "*", + "schema": { + "type": "object", + "required": "*", + "properties": "*" + } + } + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addRequestValidator": [ + "*", + { + "requestValidatorName": "*", + "validateRequestBody": true + } + ] + } + } + ], + "/model-schema-additional-items-test/model-schema-api/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "modelschemaapi9C215193" + } + ], + "/model-schema-additional-items-test/model-schema-api/Deployment": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "description": "*", + "api": "*", + "retainDeployments": "*" + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addToLogicalId": [ + {} + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addToLogicalId": [ + {} + ] + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addToLogicalId": [ + {} + ] + } + } + ], + "/model-schema-additional-items-test/model-schema-api/Deployment/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "modelschemaapiDeploymentC7D4982Cc02c0744ba09d7d641fdba42094183f8" + } + ], + "/model-schema-additional-items-test/model-schema-api/DeploymentStage.prod": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "deployment": "*" + } + } + ], + "/model-schema-additional-items-test/model-schema-api/DeploymentStage.prod/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "modelschemaapiDeploymentStageprodEF543582" + } + ], + "/model-schema-additional-items-test/model-schema-api/Endpoint": [ + { + "type": "aws:cdk:logicalId", + "data": "modelschemaapiEndpoint16CC9BD3" + } + ], + "/model-schema-additional-items-test/model-schema-api/Default": [ + { + "type": "aws:cdk:analytics:construct", + "data": "*" + } + ], + "/model-schema-additional-items-test/model-schema-api/Default/POST": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "resource": "*", + "httpMethod": "*", + "integration": "*", + "options": { + "requestValidator": "*", + "requestModels": "*", + "methodResponses": [ + { + "statusCode": "*" + } + ] + } + } + }, + { + "type": "aws:cdk:analytics:method", + "data": { + "addMethodResponse": [ + { + "statusCode": "*" + } + ] + } + } + ], + "/model-schema-additional-items-test/model-schema-api/Default/POST/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "modelschemaapiPOST5FB5AEAA" + } + ], + "/model-schema-additional-items-test/model-schema-api/TagsModel": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "contentType": "*", + "modelName": "*", + "schema": { + "type": "object", + "required": "*", + "properties": "*" + }, + "restApi": "*" + } + } + ], + "/model-schema-additional-items-test/model-schema-api/TagsModel/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "modelschemaapiTagsModelFCCA8255" + } + ], + "/model-schema-additional-items-test/model-schema-api/TagsValidator": [ + { + "type": "aws:cdk:analytics:construct", + "data": { + "requestValidatorName": "*", + "validateRequestBody": true, + "restApi": "*" + } + } + ], + "/model-schema-additional-items-test/model-schema-api/TagsValidator/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "modelschemaapiTagsValidatorB38D3476" + } + ], + "/model-schema-additional-items-test/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/model-schema-additional-items-test/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "model-schema-additional-items-test" + }, + "ModelSchemaAdditionalItemsTestDefaultTestDeployAssert81CF581B.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "ModelSchemaAdditionalItemsTestDefaultTestDeployAssert81CF581B.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "ModelSchemaAdditionalItemsTestDefaultTestDeployAssert81CF581B": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "ModelSchemaAdditionalItemsTestDefaultTestDeployAssert81CF581B.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "ModelSchemaAdditionalItemsTestDefaultTestDeployAssert81CF581B.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "ModelSchemaAdditionalItemsTestDefaultTestDeployAssert81CF581B.assets" + ], + "metadata": { + "/ModelSchemaAdditionalItemsTest/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/ModelSchemaAdditionalItemsTest/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "ModelSchemaAdditionalItemsTest/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/model-schema-additional-items-test.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/model-schema-additional-items-test.assets.json new file mode 100644 index 0000000000000..c640b4978cd7f --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/model-schema-additional-items-test.assets.json @@ -0,0 +1,19 @@ +{ + "version": "40.0.0", + "files": { + "b49c1b4daac47f77703412f366f4599fffc5e3f904aaf1dc3bc06abcb953c26e": { + "source": { + "path": "model-schema-additional-items-test.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "b49c1b4daac47f77703412f366f4599fffc5e3f904aaf1dc3bc06abcb953c26e.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/model-schema-additional-items-test.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/model-schema-additional-items-test.template.json new file mode 100644 index 0000000000000..5dce75c025286 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/model-schema-additional-items-test.template.json @@ -0,0 +1,190 @@ +{ + "Resources": { + "modelschemaapi9C215193": { + "Type": "AWS::ApiGateway::RestApi", + "Properties": { + "Name": "Model Schema Test API" + } + }, + "modelschemaapiDeploymentC7D4982Cc02c0744ba09d7d641fdba42094183f8": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "Description": "Automatically created by the RestApi construct", + "RestApiId": { + "Ref": "modelschemaapi9C215193" + } + }, + "DependsOn": [ + "modelschemaapiPOST5FB5AEAA", + "modelschemaapiTagsModelFCCA8255", + "modelschemaapiTagsValidatorB38D3476" + ] + }, + "modelschemaapiDeploymentStageprodEF543582": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "DeploymentId": { + "Ref": "modelschemaapiDeploymentC7D4982Cc02c0744ba09d7d641fdba42094183f8" + }, + "RestApiId": { + "Ref": "modelschemaapi9C215193" + }, + "StageName": "prod" + } + }, + "modelschemaapiPOST5FB5AEAA": { + "Type": "AWS::ApiGateway::Method", + "Properties": { + "AuthorizationType": "NONE", + "HttpMethod": "POST", + "Integration": { + "IntegrationResponses": [ + { + "StatusCode": "200" + } + ], + "RequestTemplates": { + "application/json": "{ \"statusCode\": 200 }" + }, + "Type": "MOCK" + }, + "MethodResponses": [ + { + "StatusCode": "200" + } + ], + "RequestModels": { + "application/json": { + "Ref": "modelschemaapiTagsModelFCCA8255" + } + }, + "RequestValidatorId": { + "Ref": "modelschemaapiTagsValidatorB38D3476" + }, + "ResourceId": { + "Fn::GetAtt": [ + "modelschemaapi9C215193", + "RootResourceId" + ] + }, + "RestApiId": { + "Ref": "modelschemaapi9C215193" + } + } + }, + "modelschemaapiTagsModelFCCA8255": { + "Type": "AWS::ApiGateway::Model", + "Properties": { + "ContentType": "application/json", + "Name": "Tags", + "RestApiId": { + "Ref": "modelschemaapi9C215193" + }, + "Schema": { + "type": "object", + "required": [ + "tags" + ], + "properties": { + "tags": { + "type": "array", + "items": [ + { + "type": "string", + "enum": [ + "primary" + ] + }, + { + "type": "string", + "enum": [ + "secondary" + ] + } + ], + "additionalItems": { + "type": "string", + "pattern": "^[a-z0-9-]+$" + }, + "minItems": 1, + "maxItems": 5 + } + }, + "$schema": "http://json-schema.org/draft-04/schema#" + } + } + }, + "modelschemaapiTagsValidatorB38D3476": { + "Type": "AWS::ApiGateway::RequestValidator", + "Properties": { + "Name": "TagsValidator", + "RestApiId": { + "Ref": "modelschemaapi9C215193" + }, + "ValidateRequestBody": true + } + } + }, + "Outputs": { + "modelschemaapiEndpoint16CC9BD3": { + "Value": { + "Fn::Join": [ + "", + [ + "https://", + { + "Ref": "modelschemaapi9C215193" + }, + ".execute-api.", + { + "Ref": "AWS::Region" + }, + ".", + { + "Ref": "AWS::URLSuffix" + }, + "/", + { + "Ref": "modelschemaapiDeploymentStageprodEF543582" + }, + "/" + ] + ] + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value<String>", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/tree.json new file mode 100644 index 0000000000000..5434fe46ace26 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.js.snapshot/tree.json @@ -0,0 +1 @@ +{"version":"tree-0.1","tree":{"id":"App","path":"","children":{"model-schema-additional-items-test":{"id":"model-schema-additional-items-test","path":"model-schema-additional-items-test","children":{"model-schema-api":{"id":"model-schema-api","path":"model-schema-additional-items-test/model-schema-api","children":{"Resource":{"id":"Resource","path":"model-schema-additional-items-test/model-schema-api/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::ApiGateway::RestApi","aws:cdk:cloudformation:props":{"name":"Model Schema Test API"}},"constructInfo":{"fqn":"aws-cdk-lib.aws_apigateway.CfnRestApi","version":"0.0.0"}},"Deployment":{"id":"Deployment","path":"model-schema-additional-items-test/model-schema-api/Deployment","children":{"Resource":{"id":"Resource","path":"model-schema-additional-items-test/model-schema-api/Deployment/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::ApiGateway::Deployment","aws:cdk:cloudformation:props":{"description":"Automatically created by the RestApi construct","restApiId":{"Ref":"modelschemaapi9C215193"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_apigateway.CfnDeployment","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_apigateway.Deployment","version":"0.0.0","metadata":[{"description":"*","api":"*","retainDeployments":"*"},{"addToLogicalId":[{}]},{"addToLogicalId":[{}]},{"addToLogicalId":[{}]}]}},"DeploymentStage.prod":{"id":"DeploymentStage.prod","path":"model-schema-additional-items-test/model-schema-api/DeploymentStage.prod","children":{"Resource":{"id":"Resource","path":"model-schema-additional-items-test/model-schema-api/DeploymentStage.prod/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::ApiGateway::Stage","aws:cdk:cloudformation:props":{"deploymentId":{"Ref":"modelschemaapiDeploymentC7D4982Cc02c0744ba09d7d641fdba42094183f8"},"restApiId":{"Ref":"modelschemaapi9C215193"},"stageName":"prod"}},"constructInfo":{"fqn":"aws-cdk-lib.aws_apigateway.CfnStage","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_apigateway.Stage","version":"0.0.0","metadata":[{"deployment":"*"}]}},"Endpoint":{"id":"Endpoint","path":"model-schema-additional-items-test/model-schema-api/Endpoint","constructInfo":{"fqn":"aws-cdk-lib.CfnOutput","version":"0.0.0"}},"Default":{"id":"Default","path":"model-schema-additional-items-test/model-schema-api/Default","children":{"POST":{"id":"POST","path":"model-schema-additional-items-test/model-schema-api/Default/POST","children":{"Resource":{"id":"Resource","path":"model-schema-additional-items-test/model-schema-api/Default/POST/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::ApiGateway::Method","aws:cdk:cloudformation:props":{"authorizationType":"NONE","httpMethod":"POST","integration":{"type":"MOCK","requestTemplates":{"application/json":"{ \"statusCode\": 200 }"},"integrationResponses":[{"statusCode":"200"}]},"methodResponses":[{"statusCode":"200"}],"requestModels":{"application/json":{"Ref":"modelschemaapiTagsModelFCCA8255"}},"requestValidatorId":{"Ref":"modelschemaapiTagsValidatorB38D3476"},"resourceId":{"Fn::GetAtt":["modelschemaapi9C215193","RootResourceId"]},"restApiId":{"Ref":"modelschemaapi9C215193"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_apigateway.CfnMethod","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_apigateway.Method","version":"0.0.0","metadata":[{"resource":"*","httpMethod":"*","integration":"*","options":{"requestValidator":"*","requestModels":"*","methodResponses":[{"statusCode":"*"}]}},{"addMethodResponse":[{"statusCode":"*"}]}]}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_apigateway.ResourceBase","version":"0.0.0","metadata":["*"]}},"TagsModel":{"id":"TagsModel","path":"model-schema-additional-items-test/model-schema-api/TagsModel","children":{"Resource":{"id":"Resource","path":"model-schema-additional-items-test/model-schema-api/TagsModel/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::ApiGateway::Model","aws:cdk:cloudformation:props":{"contentType":"application/json","name":"Tags","restApiId":{"Ref":"modelschemaapi9C215193"},"schema":{"type":"object","required":["tags"],"properties":{"tags":{"type":"array","items":[{"type":"string","enum":["primary"]},{"type":"string","enum":["secondary"]}],"additionalItems":{"type":"string","pattern":"^[a-z0-9-]+$"},"minItems":1,"maxItems":5}},"$schema":"http://json-schema.org/draft-04/schema#"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_apigateway.CfnModel","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_apigateway.Model","version":"0.0.0","metadata":[{"contentType":"*","modelName":"*","schema":{"type":"object","required":"*","properties":"*"},"restApi":"*"}]}},"TagsValidator":{"id":"TagsValidator","path":"model-schema-additional-items-test/model-schema-api/TagsValidator","children":{"Resource":{"id":"Resource","path":"model-schema-additional-items-test/model-schema-api/TagsValidator/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::ApiGateway::RequestValidator","aws:cdk:cloudformation:props":{"name":"TagsValidator","restApiId":{"Ref":"modelschemaapi9C215193"},"validateRequestBody":true}},"constructInfo":{"fqn":"aws-cdk-lib.aws_apigateway.CfnRequestValidator","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_apigateway.RequestValidator","version":"0.0.0","metadata":[{"requestValidatorName":"*","validateRequestBody":true,"restApi":"*"}]}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_apigateway.RestApi","version":"0.0.0","metadata":[{"restApiName":"*"},{"addModel":["*",{"contentType":"*","modelName":"*","schema":{"type":"object","required":"*","properties":"*"}}]},{"addRequestValidator":["*",{"requestValidatorName":"*","validateRequestBody":true}]}]}},"BootstrapVersion":{"id":"BootstrapVersion","path":"model-schema-additional-items-test/BootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnParameter","version":"0.0.0"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"model-schema-additional-items-test/CheckBootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnRule","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.Stack","version":"0.0.0"}},"ModelSchemaAdditionalItemsTest":{"id":"ModelSchemaAdditionalItemsTest","path":"ModelSchemaAdditionalItemsTest","children":{"DefaultTest":{"id":"DefaultTest","path":"ModelSchemaAdditionalItemsTest/DefaultTest","children":{"Default":{"id":"Default","path":"ModelSchemaAdditionalItemsTest/DefaultTest/Default","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}},"DeployAssert":{"id":"DeployAssert","path":"ModelSchemaAdditionalItemsTest/DefaultTest/DeployAssert","children":{"BootstrapVersion":{"id":"BootstrapVersion","path":"ModelSchemaAdditionalItemsTest/DefaultTest/DeployAssert/BootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnParameter","version":"0.0.0"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"ModelSchemaAdditionalItemsTest/DefaultTest/DeployAssert/CheckBootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnRule","version":"0.0.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.Stack","version":"0.0.0"}}},"constructInfo":{"fqn":"@aws-cdk/integ-tests-alpha.IntegTestCase","version":"0.0.0"}}},"constructInfo":{"fqn":"@aws-cdk/integ-tests-alpha.IntegTest","version":"0.0.0"}},"Tree":{"id":"Tree","path":"Tree","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"aws-cdk-lib.App","version":"0.0.0"}}} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.ts new file mode 100644 index 0000000000000..3dbc2f28577c8 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.model-schema-additional-items.ts @@ -0,0 +1,72 @@ +import * as cdk from 'aws-cdk-lib'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; +import * as apigateway from 'aws-cdk-lib/aws-apigateway'; + +class TestStack extends cdk.Stack { + constructor(scope: cdk.App, id: string) { + super(scope, id); + + const api = new apigateway.RestApi(this, 'model-schema-api', { + restApiName: 'Model Schema Test API', + }); + + // Create a minimal schema that uses additionalItems + const schema: apigateway.JsonSchema = { + type: apigateway.JsonSchemaType.OBJECT, + required: ['tags'], + properties: { + tags: { + type: apigateway.JsonSchemaType.ARRAY, + items: [ + { type: apigateway.JsonSchemaType.STRING, enum: ['primary'] }, + { type: apigateway.JsonSchemaType.STRING, enum: ['secondary'] }, + ], + additionalItems: { + type: apigateway.JsonSchemaType.STRING, + pattern: '^[a-z0-9-]+$', + }, + minItems: 1, + maxItems: 5, + }, + }, + }; + + // Create the model using our schema + const model = api.addModel('TagsModel', { + contentType: 'application/json', + modelName: 'Tags', + schema: schema, + }); + + // Add a validator that requires the request body to match our model + const validator = api.addRequestValidator('TagsValidator', { + requestValidatorName: 'TagsValidator', + validateRequestBody: true, + }); + + // Add a POST method that uses the model and validator + api.root.addMethod('POST', new apigateway.MockIntegration({ + integrationResponses: [{ + statusCode: '200', + }], + requestTemplates: { + 'application/json': '{ "statusCode": 200 }', + }, + }), { + requestValidator: validator, + requestModels: { + 'application/json': model, + }, + methodResponses: [{ + statusCode: '200', + }], + }); + } +} + +const app = new cdk.App(); +const stack = new TestStack(app, 'model-schema-additional-items-test'); +new IntegTest(app, 'ModelSchemaAdditionalItemsTest', { + testCases: [stack], +}); +app.synth(); diff --git a/packages/aws-cdk-lib/aws-apigateway/lib/json-schema.ts b/packages/aws-cdk-lib/aws-apigateway/lib/json-schema.ts index 72fe361d50b1f..e11afa9ac683a 100644 --- a/packages/aws-cdk-lib/aws-apigateway/lib/json-schema.ts +++ b/packages/aws-cdk-lib/aws-apigateway/lib/json-schema.ts @@ -58,7 +58,7 @@ export interface JsonSchema { // Array readonly items?: JsonSchema | JsonSchema[]; - readonly additionalItems?: JsonSchema[]; + readonly additionalItems?: JsonSchema | boolean; readonly maxItems?: number; readonly minItems?: number; readonly uniqueItems?: boolean;