Skip to content

Commit 5187b5b

Browse files
AllanZhengYPsrchase
authored andcommitted
fix serializer throw at writing host prefix (smithy-lang#206)
1 parent 93f5711 commit 5187b5b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpProtocolGeneratorUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static void writeHostPrefix(GenerationContext context, OperationShape operation)
380380
TypeScriptWriter writer = context.getWriter();
381381
SymbolProvider symbolProvider = context.getSymbolProvider();
382382
EndpointTrait trait = operation.getTrait(EndpointTrait.class).get();
383-
writer.write("let resolvedHostname = (context.endpoint as any).hostname;");
383+
writer.write("let { hostname: resolvedHostname } = await context.endpoint();");
384384
// Check if disableHostPrefixInjection has been set to true at runtime
385385
writer.openBlock("if (context.disableHostPrefix !== true) {", "}", () -> {
386386
writer.addImport("isValidHostname", "__isValidHostname",

smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/integration/HttpProtocolGeneratorUtilsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void writesCorrectHostPrefix() {
6464

6565
OperationShape operation = (OperationShape) model.expectShape(ShapeId.from("smithy.example#GetFoo"));
6666
HttpProtocolGeneratorUtils.writeHostPrefix(mockContext, operation);
67-
assertThat(writer.toString(), containsString("let resolvedHostname = (context.endpoint as any).hostname;"));
67+
assertThat(writer.toString(), containsString("let { hostname: resolvedHostname } = await context.endpoint();"));
6868
assertThat(writer.toString(), containsString("if (context.disableHostPrefix !== true) {"));
6969
assertThat(writer.toString(), containsString("resolvedHostname = \"{foo}.data.\" + resolvedHostname;"));
7070
assertThat(writer.toString(), containsString("resolvedHostname = resolvedHostname.replace(\"{foo}\", input.foo)"));

0 commit comments

Comments
 (0)