diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java index c6f7c35d170..69cd00f714b 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java @@ -58,6 +58,7 @@ import software.amazon.smithy.typescript.codegen.sections.CommandPropertiesCodeSection; import software.amazon.smithy.typescript.codegen.sections.PreCommandClassCodeSection; import software.amazon.smithy.typescript.codegen.sections.SmithyContextCodeSection; +import software.amazon.smithy.typescript.codegen.util.CommandWriterConsumer; import software.amazon.smithy.typescript.codegen.validation.SensitiveDataFinder; import software.amazon.smithy.utils.SmithyInternalApi; @@ -467,15 +468,11 @@ private void addCommandSpecificPlugins() { // applied automatically when the Command's middleware stack is copied from // the service's middleware stack. for (RuntimeClientPlugin plugin : runtimePlugins) { - plugin.getWriterConsumer().accept(writer); plugin.getPluginFunction().ifPresent(pluginSymbol -> { // Construct additional parameters string Map paramsMap = plugin.getAdditionalPluginFunctionParameters( model, service, operation); - List additionalParameters = CodegenUtils.getFunctionParametersList(paramsMap); - String additionalParamsString = additionalParameters.isEmpty() - ? "" - : ", { " + String.join(", ", additionalParameters) + " }"; + // Construct writer context Map symbolMap = new HashMap<>(); @@ -487,7 +484,29 @@ private void addCommandSpecificPlugins() { } writer.pushState(); writer.putContext(symbolMap); - writer.write("$pluginFn:T(config" + additionalParamsString + "),"); + writer.openBlock("$pluginFn:T(config", "),", () -> { + List additionalParameters = CodegenUtils.getFunctionParametersList(paramsMap); + Map clientAddParamsWriterConsumers = + plugin.getOperationAddParamsWriterConsumers(); + if (additionalParameters.isEmpty() && clientAddParamsWriterConsumers.isEmpty()) { + return; + } + writer.writeInline(", { "); + writer.writeInline(String.join(", ", additionalParameters)); + clientAddParamsWriterConsumers.forEach((key, consumer) -> { + writer.writeInline(key).writeInline(": "); + consumer.accept(writer, CommandConstructorCodeSection.builder() + .settings(settings) + .model(model) + .service(service) + .symbolProvider(symbolProvider) + .runtimeClientPlugins(runtimePlugins) + .applicationProtocol(applicationProtocol) + .build()); + writer.writeInline(","); + }); + writer.writeInline(" }"); + }); writer.popState(); }); } diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGenerator.java index 6982dbe4cf0..7c58f44ee19 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGenerator.java @@ -41,6 +41,7 @@ import software.amazon.smithy.typescript.codegen.sections.ClientConstructorCodeSection; import software.amazon.smithy.typescript.codegen.sections.ClientDestroyCodeSection; import software.amazon.smithy.typescript.codegen.sections.ClientPropertiesCodeSection; +import software.amazon.smithy.typescript.codegen.util.ClientWriterConsumer; import software.amazon.smithy.utils.OptionalUtils; import software.amazon.smithy.utils.SmithyInternalApi; @@ -63,13 +64,13 @@ public final class ServiceBareBonesClientGenerator implements Runnable { private final ApplicationProtocol applicationProtocol; ServiceBareBonesClientGenerator( - TypeScriptSettings settings, - Model model, - SymbolProvider symbolProvider, - TypeScriptWriter writer, - List integrations, - List runtimePlugins, - ApplicationProtocol applicationProtocol + TypeScriptSettings settings, + Model model, + SymbolProvider symbolProvider, + TypeScriptWriter writer, + List integrations, + List runtimePlugins, + ApplicationProtocol applicationProtocol ) { this.settings = settings; this.model = model; @@ -387,10 +388,6 @@ private void generateConstructor() { generateConfigVariable(configVariable - 1)); } - for (RuntimeClientPlugin plugin : runtimePlugins) { - plugin.getWriterConsumer().accept(writer); - } - // Add runtime plugin "resolve" method calls. These are invoked one // after the other until all of the runtime plugins have been called. // Only plugins that have configuration are called. Each time the @@ -442,10 +439,6 @@ private void generateConstructor() { // Construct additional parameters string Map paramsMap = plugin.getAdditionalPluginFunctionParameters( model, service, null); - List additionalParameters = CodegenUtils.getFunctionParametersList(paramsMap); - String additionalParamsString = additionalParameters.isEmpty() - ? "" - : ", { " + String.join(", ", additionalParameters) + " }"; // Construct writer context Map symbolMap = new HashMap<>(); @@ -457,7 +450,32 @@ private void generateConstructor() { } writer.pushState(); writer.putContext(symbolMap); - writer.write("this.middlewareStack.use($pluginFn:T(this.config" + additionalParamsString + "));"); + writer.openBlock("this.middlewareStack.use($pluginFn:T(this.config", "));", () -> { + List additionalParameters = CodegenUtils.getFunctionParametersList(paramsMap); + Map clientAddParamsWriterConsumers = + plugin.getClientAddParamsWriterConsumers(); + + if (additionalParameters.isEmpty() && clientAddParamsWriterConsumers.isEmpty()) { + return; + } + + writer.writeInline(", {"); + writer.writeInline(String.join(", ", additionalParameters)); + clientAddParamsWriterConsumers.forEach((key, consumer) -> { + writer.writeInline(key).writeInline(": "); + consumer.accept(writer, ClientBodyExtraCodeSection.builder() + .settings(settings) + .model(model) + .service(service) + .symbolProvider(symbolProvider) + .integrations(integrations) + .runtimeClientPlugins(runtimePlugins) + .applicationProtocol(applicationProtocol) + .build()); + writer.writeInline(","); + }); + writer.writeInline("}"); + }); writer.popState(); }); } diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/auth/http/integration/AddHttpAuthSchemePlugin.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/auth/http/integration/AddHttpAuthSchemePlugin.java index c6b8b523026..8771af17dfa 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/auth/http/integration/AddHttpAuthSchemePlugin.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/auth/http/integration/AddHttpAuthSchemePlugin.java @@ -32,9 +32,7 @@ import software.amazon.smithy.typescript.codegen.auth.http.sections.ResolveHttpAuthSchemeConfigFunctionReturnBlockCodeSection; import software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin; import software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin.Convention; -import software.amazon.smithy.typescript.codegen.sections.ClientBodyExtraCodeSection; -import software.amazon.smithy.utils.CodeInterceptor; -import software.amazon.smithy.utils.CodeSection; +import software.amazon.smithy.typescript.codegen.util.ClientWriterConsumer; import software.amazon.smithy.utils.SmithyInternalApi; /** @@ -52,6 +50,51 @@ public boolean matchesSettings(TypeScriptSettings settings) { @Override public List getClientPlugins() { + Map httpAuthSchemeParametersProvider = Map.of( + "httpAuthSchemeParametersProvider", (w, clientBodySection) -> { + String httpAuthSchemeParametersProviderName = "default" + + CodegenUtils.getServiceName( + clientBodySection.getSettings(), + clientBodySection.getModel(), + clientBodySection.getSymbolProvider() + ) + + "HttpAuthSchemeParametersProvider"; + w.addImport(httpAuthSchemeParametersProviderName, null, AuthUtils.AUTH_HTTP_PROVIDER_DEPENDENCY); + w.writeInline(httpAuthSchemeParametersProviderName); + }, + "identityProviderConfigProvider", (w, s) -> { + w.addDependency(TypeScriptDependency.SMITHY_CORE); + w.addImport("DefaultIdentityProviderConfig", null, TypeScriptDependency.SMITHY_CORE); + w.openBlock(""" + async (config: $LResolvedConfig) => \ + new DefaultIdentityProviderConfig({""", "})", + s.getSymbolProvider().toSymbol(s.getService()).getName(), + () -> { + SupportedHttpAuthSchemesIndex authIndex = new SupportedHttpAuthSchemesIndex( + s.getIntegrations(), + s.getModel(), + s.getSettings()); + ServiceIndex serviceIndex = ServiceIndex.of(s.getModel()); + TopDownIndex topDownIndex = TopDownIndex.of(s.getModel()); + Map httpAuthSchemes = AuthUtils.getAllEffectiveNoAuthAwareAuthSchemes( + s.getService(), serviceIndex, authIndex, topDownIndex); + for (HttpAuthScheme scheme : httpAuthSchemes.values()) { + if (scheme == null) { + continue; + } + for (ConfigField configField : scheme.getConfigFields()) { + if (configField.type().equals(ConfigField.Type.MAIN)) { + w.writeInline( + "$S: config.$L,", + scheme.getSchemeId().toString(), + configField.name() + ); + } + } + } + }); + } + ); return List.of( RuntimeClientPlugin.builder() .servicePredicate((m, s) -> s.hasTrait(EndpointRuleSetTrait.ID)) @@ -59,20 +102,7 @@ public List getClientPlugins() { TypeScriptDependency.SMITHY_CORE.dependency, "HttpAuthSchemeEndpointRuleSet", Convention.HAS_MIDDLEWARE) - .additionalPluginFunctionParamsSupplier((model, service, operation) -> Map.of( - "httpAuthSchemeParametersProvider", Symbol.builder() - .name("this.getDefaultHttpAuthSchemeParametersProvider()") - .build(), - "identityProviderConfigProvider", Symbol.builder() - .name("this.getIdentityProviderConfigProvider()") - .build() - )) - .withWriter(writer -> { - String httpAuthSchemeParametersProviderName = "default" - + CodegenUtils.getServiceName(s.getSettings(), s.getModel(), s.getSymbolProvider()) - + "HttpAuthSchemeParametersProvider"; - w.addImport(httpAuthSchemeParametersProviderName, null, AuthUtils.AUTH_HTTP_PROVIDER_DEPENDENCY); - }) + .withAdditionalClientParams(httpAuthSchemeParametersProvider) .build(), RuntimeClientPlugin.builder() .servicePredicate((m, s) -> !s.hasTrait(EndpointRuleSetTrait.ID)) @@ -80,14 +110,7 @@ public List getClientPlugins() { TypeScriptDependency.SMITHY_CORE.dependency, "HttpAuthScheme", Convention.HAS_MIDDLEWARE) - .additionalPluginFunctionParamsSupplier((model, service, operation) -> Map.of( - "httpAuthSchemeParametersProvider", Symbol.builder() - .name("this.getDefaultHttpAuthSchemeParametersProvider()") - .build(), - "identityProviderConfigProvider", Symbol.builder() - .name("this.getIdentityProviderConfigProvider()") - .build() - )) + .withAdditionalClientParams(httpAuthSchemeParametersProvider) .build(), RuntimeClientPlugin.builder() .inputConfig(Symbol.builder() @@ -106,70 +129,6 @@ public List getClientPlugins() { ); } - @Override - public List> interceptors( - TypeScriptCodegenContext codegenContext - ) { - return List.of(CodeInterceptor.appender(ClientBodyExtraCodeSection.class, (w, s) -> { - if (!s.getSettings().generateClient() - || s.getSettings().useLegacyAuth() - || !s.getApplicationProtocol().isHttpProtocol()) { - return; - } - - /* - private getDefaultHttpAuthSchemeParametersProvider() { - return defaultWeatherHttpAuthSchemeParametersProvider; - } - */ - w.openBlock("private getDefaultHttpAuthSchemeParametersProvider() {", "}", () -> { - String httpAuthSchemeParametersProviderName = "default" - + CodegenUtils.getServiceName(s.getSettings(), s.getModel(), s.getSymbolProvider()) - + "HttpAuthSchemeParametersProvider"; - w.addImport(httpAuthSchemeParametersProviderName, null, AuthUtils.AUTH_HTTP_PROVIDER_DEPENDENCY); - w.write("return " + httpAuthSchemeParametersProviderName + ";"); - }); - - /* - private getIdentityProviderConfigProvider() { - return async (config: WeatherClientResolvedConfig) => new DefaultIdentityProviderConfig({ - "aws.auth#sigv4": config.credentials, - "smithy.api#httpApiKeyAuth": config.apiKey, - "smithy.api#httpBearerAuth": config.token, - }); - } - */ - w.openBlock("private getIdentityProviderConfigProvider() {", "}", () -> { - w.addDependency(TypeScriptDependency.SMITHY_CORE); - w.addImport("DefaultIdentityProviderConfig", null, TypeScriptDependency.SMITHY_CORE); - w.openBlock(""" - return async (config: $LResolvedConfig) => \ - new DefaultIdentityProviderConfig({""", "});", - s.getSymbolProvider().toSymbol(s.getService()).getName(), - () -> { - SupportedHttpAuthSchemesIndex authIndex = new SupportedHttpAuthSchemesIndex( - s.getIntegrations(), - s.getModel(), - s.getSettings()); - ServiceIndex serviceIndex = ServiceIndex.of(s.getModel()); - TopDownIndex topDownIndex = TopDownIndex.of(s.getModel()); - Map httpAuthSchemes = AuthUtils.getAllEffectiveNoAuthAwareAuthSchemes( - s.getService(), serviceIndex, authIndex, topDownIndex); - for (HttpAuthScheme scheme : httpAuthSchemes.values()) { - if (scheme == null) { - continue; - } - for (ConfigField configField : scheme.getConfigFields()) { - if (configField.type().equals(ConfigField.Type.MAIN)) { - w.write("$S: config.$L,", scheme.getSchemeId().toString(), configField.name()); - } - } - } - }); - }); - })); - } - @Override public void customize(TypeScriptCodegenContext codegenContext) { if (!codegenContext.settings().generateClient() @@ -223,14 +182,6 @@ public void customize(TypeScriptCodegenContext codegenContext) { }); } - private String inlineHttpAuthSchemeParametersProvider() { - return ""; - } - - private String inlineIdentityProviderConfigProvider() { - return ""; - } - /* export interface HttpAuthSchemeInputConfig { httpAuthSchemes?: HttpAuthScheme[]; diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddEventStreamDependency.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddEventStreamDependency.java index 03144e11a93..94ebc6b3d40 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddEventStreamDependency.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddEventStreamDependency.java @@ -44,6 +44,13 @@ @SmithyInternalApi public final class AddEventStreamDependency implements TypeScriptIntegration { + @Override + public List runAfter() { + return List.of( + AddBuiltinPlugins.class.getCanonicalName() + ); + } + @Override public List getClientPlugins() { return ListUtils.of( diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/RuntimeClientPlugin.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/RuntimeClientPlugin.java index 8cd14933532..04adc6cb21a 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/RuntimeClientPlugin.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/RuntimeClientPlugin.java @@ -15,16 +15,13 @@ package software.amazon.smithy.typescript.codegen.integration; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; -import java.util.function.BiConsumer; import java.util.function.BiPredicate; -import java.util.function.Consumer; -import java.util.function.UnaryOperator; - import software.amazon.smithy.codegen.core.Symbol; import software.amazon.smithy.codegen.core.SymbolDependency; import software.amazon.smithy.codegen.core.SymbolReference; @@ -33,12 +30,12 @@ import software.amazon.smithy.model.shapes.ServiceShape; import software.amazon.smithy.typescript.codegen.TypeScriptDependency; import software.amazon.smithy.typescript.codegen.TypeScriptSettings; -import software.amazon.smithy.typescript.codegen.TypeScriptWriter; +import software.amazon.smithy.typescript.codegen.util.ClientWriterConsumer; +import software.amazon.smithy.typescript.codegen.util.CommandWriterConsumer; import software.amazon.smithy.utils.SmithyBuilder; import software.amazon.smithy.utils.SmithyUnstableApi; import software.amazon.smithy.utils.StringUtils; import software.amazon.smithy.utils.ToSmithyBuilder; -import software.amazon.smithy.utils.TriConsumer; /** * Represents a runtime plugin for a client that hooks into various aspects @@ -62,8 +59,8 @@ public final class RuntimeClientPlugin implements ToSmithyBuilder servicePredicate; private final OperationPredicate operationPredicate; private final SettingsPredicate settingsPredicate; - private BiConsumer> clientWriterConsumer = (writer, consumer) -> {}; - private BiConsumer> operationWriterConsumer = (writer, consumer) -> {}; + private final Map writeAdditionalClientParams; + private final Map writeAdditionalOperationParams; private RuntimeClientPlugin(Builder builder) { inputConfig = builder.inputConfig; @@ -76,8 +73,8 @@ private RuntimeClientPlugin(Builder builder) { operationPredicate = builder.operationPredicate; servicePredicate = builder.servicePredicate; settingsPredicate = builder.settingsPredicate; - clientWriterConsumer = builder.clientWriterConsumer; - operationWriterConsumer = builder.operationWriterConsumer; + writeAdditionalClientParams = builder.writeAdditionalClientParams; + writeAdditionalOperationParams = builder.writeAdditionalOperationParams; boolean allNull = (inputConfig == null) && (resolvedConfig == null) && (resolveFunction == null); boolean allSet = (inputConfig != null) && (resolvedConfig != null) && (resolveFunction != null); @@ -268,7 +265,30 @@ public Map getAdditionalPluginFunctionParameters( if (additionalPluginFunctionParamsSupplier != null) { return additionalPluginFunctionParamsSupplier.apply(model, service, operation); } - return new HashMap(); + return new HashMap<>(); + } + + /** + * Gets a list of additional parameters to be supplied to the + * plugin function. These parameters are to be supplied to plugin + * function as second argument. The map is empty if there are + * no additional parameters. + * + * @param model Model the operation belongs to. + * @param service Service the operation belongs to. + * @param operation Operation to test against. + * @return Returns the optionally present map of parameters. The key is the key + * for a parameter, and value is the value for a parameter. + */ + public Map getAdditionalPluginFunctionParameterWriterConsumers( + Model model, + ServiceShape service, + OperationShape operation + ) { + if (additionalPluginFunctionParamsSupplier != null) { + return additionalPluginFunctionParamsSupplier.apply(model, service, operation); + } + return new HashMap<>(); } /** @@ -337,15 +357,19 @@ public boolean matchesSettings(Model model, ServiceShape service, TypeScriptSett } /** - * @return the writer consumer for this RuntimeClientPlugin. May be used to add imports and dependencies - * used by this plugin. + * @return the map of additional client level plugin params and their writer consumers used + * to populate the param values. */ - public Consumer getClientWriterConsumer() { - return this.clientWriterConsumer; + public Map getClientAddParamsWriterConsumers() { + return this.writeAdditionalClientParams; } - public Consumer getClientWriterConsumer() { - return this.operationWriterConsumer; + /** + * @return the map of additional operation level plugin params and their writer consumers used + * to populate the param values. + */ + public Map getOperationAddParamsWriterConsumers() { + return this.writeAdditionalOperationParams; } public static Builder builder() { @@ -420,8 +444,8 @@ public static final class Builder implements SmithyBuilder private BiPredicate servicePredicate = (model, service) -> true; private OperationPredicate operationPredicate = (model, service, operation) -> false; private SettingsPredicate settingsPredicate = (model, service, settings) -> true; - private BiConsumer> clientWriterConsumer = (writer, consumer) -> {}; - private BiConsumer> operationWriterConsumer = (writer, consumer) -> {}; + private Map writeAdditionalClientParams = Collections.emptyMap(); + private Map writeAdditionalOperationParams = Collections.emptyMap(); @Override public RuntimeClientPlugin build() { @@ -773,22 +797,18 @@ public Builder servicePredicate(BiPredicate servicePredicat /** * Enables access to the writer for adding imports/dependencies. */ - public Builder withClientWriter( - BiConsumer> clientWriterConsumer - ) { - this.clientWriterConsumer = clientWriterConsumer; + public Builder withAdditionalClientParams(Map writeAdditionalClientParams) { + this.writeAdditionalClientParams = writeAdditionalClientParams; return this; } /** * Enables access to the writer for adding imports/dependencies. */ - public Builder withOperationWriter( - BiConsumer> operationWriterConsumer + public Builder withAdditionalOperationParams( + Map writeAdditionalOperationParams ) { - this.operationWriterConsumer = operationWriterConsumer; + this.writeAdditionalOperationParams = writeAdditionalOperationParams; return this; } diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/util/ClientWriterConsumer.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/util/ClientWriterConsumer.java new file mode 100644 index 00000000000..62290dcfe7b --- /dev/null +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/util/ClientWriterConsumer.java @@ -0,0 +1,20 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.typescript.codegen.util; + +import software.amazon.smithy.typescript.codegen.TypeScriptWriter; +import software.amazon.smithy.typescript.codegen.sections.ClientBodyExtraCodeSection; +import software.amazon.smithy.utils.SmithyInternalApi; + +/** + * The writer consumer for a RuntimeClientPlugin. May be used to add imports and dependencies + * used by the plugin at the client level. + */ +@FunctionalInterface +@SmithyInternalApi +public interface ClientWriterConsumer { + void accept(TypeScriptWriter writer, ClientBodyExtraCodeSection section); +} diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/util/CommandWriterConsumer.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/util/CommandWriterConsumer.java new file mode 100644 index 00000000000..1eed5a9db8a --- /dev/null +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/util/CommandWriterConsumer.java @@ -0,0 +1,20 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.typescript.codegen.util; + +import software.amazon.smithy.typescript.codegen.TypeScriptWriter; +import software.amazon.smithy.typescript.codegen.sections.CommandConstructorCodeSection; +import software.amazon.smithy.utils.SmithyInternalApi; + +/** + * The writer consumer for a RuntimeClientPlugin. May be used to add imports and dependencies + * used by the plugin at the command level. + */ +@FunctionalInterface +@SmithyInternalApi +public interface CommandWriterConsumer { + void accept(TypeScriptWriter writer, CommandConstructorCodeSection section); +} diff --git a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/integration/AddHttpApiKeyAuthPluginTest.java b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/integration/AddHttpApiKeyAuthPluginTest.java index 1d571f681df..d3ee15cab99 100644 --- a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/integration/AddHttpApiKeyAuthPluginTest.java +++ b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/integration/AddHttpApiKeyAuthPluginTest.java @@ -61,7 +61,7 @@ private void testInjects(String filename, String extra) { assertThat(manifest.getFileString(CodegenUtils.SOURCE_FOLDER + "/commands/GetFooCommand.ts").get(), containsString("from \"../middleware/HttpApiKeyAuth\"")); assertThat(manifest.getFileString(CodegenUtils.SOURCE_FOLDER + "/commands/GetFooCommand.ts").get(), - containsString("getHttpApiKeyAuthPlugin(config" + extra + ")")); + containsString("getHttpApiKeyAuthPlugin(config\n " + extra)); // Ensure that the GetBar operation does not import the middleware or use it. assertThat(manifest.getFileString(CodegenUtils.SOURCE_FOLDER + "/commands/GetBarCommand.ts").get(),