Skip to content

Commit a4fb2d4

Browse files
authoredJan 9, 2025··
fix(codegen): handle case when sample operation not found (#6788)
1 parent 8386f86 commit a4fb2d4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

‎codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsPackageFixturesGeneratorIntegration.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,14 @@ private void writeAdditionalFiles(
106106
OperationShape sampleOperation =
107107
getPreferredExampleOperation(topDownIndex.getContainedOperations(service), model);
108108

109-
String operationName = sampleOperation.getId().getName(service);
109+
String operationName =
110+
sampleOperation == null
111+
? "Example"
112+
: sampleOperation.getId().getName(service);
113+
110114
resource = resource.replaceAll(Pattern.quote("${commandName}"), operationName);
111115
resource = resource.replaceAll(Pattern.quote("${operationName}"),
112-
operationName.substring(0, 1).toLowerCase() + operationName.substring(1));
116+
operationName.substring(0, 1).toLowerCase() + operationName.substring(1));
113117

114118
writer.write(resource.replaceAll(Pattern.quote("$"), Matcher.quoteReplacement("$$")));
115119
writeOperationList(writer, model, settings);

0 commit comments

Comments
 (0)
Please sign in to comment.