Skip to content

Commit 0891da5

Browse files
committed
chore(codegen): escape the service doc containing $
1 parent b2c026f commit 0891da5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Calendar;
2222
import java.util.function.BiConsumer;
2323
import java.util.function.Consumer;
24+
import java.util.regex.Matcher;
2425
import java.util.regex.Pattern;
2526
import java.util.stream.Collectors;
2627
import software.amazon.smithy.aws.traits.ServiceTrait;
@@ -78,7 +79,7 @@ public void writeAdditionalFiles(
7879
String documentation = Arrays.asList(rawDocumentation.split("\n")).stream()
7980
.map(StringUtils::trim)
8081
.collect(Collectors.joining("\n"));
81-
resource = resource.replaceAll(Pattern.quote("${documentation}"), documentation);
82+
resource = resource.replaceAll(Pattern.quote("${documentation}"), Matcher.quoteReplacement(documentation));
8283

8384
TopDownIndex topDownIndex = TopDownIndex.of(model);
8485
OperationShape firstOperation = topDownIndex.getContainedOperations(service).iterator().next();
@@ -87,7 +88,7 @@ public void writeAdditionalFiles(
8788
resource = resource.replaceAll(Pattern.quote("${operationName}"),
8889
operationName.substring(0, 1).toLowerCase() + operationName.substring(1));
8990

90-
writer.write(resource);
91+
writer.write(resource.replaceAll(Pattern.quote("$"), Matcher.quoteReplacement("$$")));
9192
});
9293
}
9394
}

codegen/smithy-aws-typescript-codegen/src/test/resources/software/amazon/smithy/aws/typescript/codegen/NotSame.smithy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ use aws.protocols#restJson1
55
@aws.api#service(sdkId: "Not Same")
66
@restJson1
77
@aws.auth#sigv4(name: "notsame")
8+
@documentation("some doc with ${str_to_escape}")
89
service OriginalName {
910
version: "2019-10-15",
10-
operations: [GetFoo]
11+
operations: [GetFoo],
1112
}
1213

1314
operation GetFoo {

0 commit comments

Comments
 (0)