Skip to content

Commit 65937a2

Browse files
rix0rrrgithub-actions
andauthored
fix(cloud-assembly-schema): add a valid example for CcApiContextQuery (#538)
This type is being exposed as-is in the CDK library, by copying it into the public API surface. It therefore gets processed by jsii, and examples get generated for it. Because we don't have an example for this type and jsii cannot express string literal types, the automatically generated example is based off the type `string` and looks like this: ```ts { expectedMatchCount: 'expectedMatchCount', } ``` This example does not compile because the generated value does not conform to the actual declared type. To solve this, we add a valid example here into the base code. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license --------- Signed-off-by: github-actions <github-actions@github.com> Co-authored-by: github-actions <github-actions@github.com>
1 parent 95971c0 commit 65937a2

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

packages/@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/context-queries.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,21 @@ export interface KeyContextQuery extends ContextLookupRoleOptions {
356356

357357
/**
358358
* Query input for lookup up CloudFormation resources using CC API
359+
*
360+
* The example below is required to successfully compile CDK (otherwise,
361+
* the CDK build will generate a synthetic example for the below, but it
362+
* doesn't have enough type information about the literal string union
363+
* to generate a validly compiling example).
364+
*
365+
* @example
366+
* const x: CcApiContextQuery = {
367+
* typeName: 'AWS::Some::Type',
368+
* expectedMatchCount: 'exactly-one',
369+
* propertiesToReturn: ['SomeProp'],
370+
* account: '11111111111',
371+
* region: 'us-east-1',
372+
* };
373+
* console.log(x);
359374
*/
360375
export interface CcApiContextQuery extends ContextLookupRoleOptions {
361376
/**

packages/@aws-cdk/cloud-assembly-schema/schema/cloud-assembly.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@
10241024
]
10251025
},
10261026
"CcApiContextQuery": {
1027-
"description": "Query input for lookup up CloudFormation resources using CC API",
1027+
"description": "Query input for lookup up CloudFormation resources using CC API\n\nThe example below is required to successfully compile CDK (otherwise,\nthe CDK build will generate a synthetic example for the below, but it\ndoesn't have enough type information about the literal string union\nto generate a validly compiling example).",
10281028
"type": "object",
10291029
"properties": {
10301030
"typeName": {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"schemaHash": "96958a4c40e0a00e850f0c14dd6e9c0fc8db0b075f1f155cea41ab198c0514be",
3-
"revision": 43
2+
"schemaHash": "5dcc6511e8b96c378ad35c391cdc2dcbaa52d08a8015760692eaad73efc9a949",
3+
"revision": 44
44
}

0 commit comments

Comments
 (0)