Skip to content

Commit

Permalink
fix(codegen): handle case when sample operation not found (aws#6788)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe authored Jan 9, 2025
1 parent 8386f86 commit a4fb2d4
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,14 @@ private void writeAdditionalFiles(
OperationShape sampleOperation =
getPreferredExampleOperation(topDownIndex.getContainedOperations(service), model);

String operationName = sampleOperation.getId().getName(service);
String operationName =
sampleOperation == null
? "Example"
: sampleOperation.getId().getName(service);

resource = resource.replaceAll(Pattern.quote("${commandName}"), operationName);
resource = resource.replaceAll(Pattern.quote("${operationName}"),
operationName.substring(0, 1).toLowerCase() + operationName.substring(1));
operationName.substring(0, 1).toLowerCase() + operationName.substring(1));

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

0 comments on commit a4fb2d4

Please sign in to comment.