Skip to content

Commit b3f9d9f

Browse files
committed
fix: missing export for api key auth middleware
1 parent 1837734 commit b3f9d9f

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

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

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,20 @@ public final class AddHttpApiKeyAuthPlugin implements TypeScriptIntegration {
5858
*/
5959
@Override
6060
public List<RuntimeClientPlugin> getClientPlugins() {
61+
String middlewarePath = getMiddlewarePath();
6162
return ListUtils.of(
6263
// Add the config if the service uses HTTP API key authorization.
6364
RuntimeClientPlugin.builder()
6465
.inputConfig(Symbol.builder()
65-
.namespace("./" + CodegenUtils.SOURCE_FOLDER + "/middleware/HttpApiKeyAuth", "/")
66+
.namespace("./" + CodegenUtils.SOURCE_FOLDER + "/middleware/" + middlewarePath, "/")
6667
.name("HttpApiKeyAuthInputConfig")
6768
.build())
6869
.resolvedConfig(Symbol.builder()
69-
.namespace("./" + CodegenUtils.SOURCE_FOLDER + "/middleware/HttpApiKeyAuth", "/")
70+
.namespace("./" + CodegenUtils.SOURCE_FOLDER + "/middleware/" + middlewarePath, "/")
7071
.name("HttpApiKeyAuthResolvedConfig")
7172
.build())
7273
.resolveFunction(Symbol.builder()
73-
.namespace("./" + CodegenUtils.SOURCE_FOLDER + "/middleware/HttpApiKeyAuth", "/")
74+
.namespace("./" + CodegenUtils.SOURCE_FOLDER + "/middleware/" + middlewarePath, "/")
7475
.name("resolveHttpApiKeyAuthConfig")
7576
.build())
7677
.servicePredicate((m, s) -> hasEffectiveHttpApiKeyAuthTrait(m, s))
@@ -79,7 +80,7 @@ public List<RuntimeClientPlugin> getClientPlugins() {
7980
// Add the middleware to operations that use HTTP API key authorization.
8081
RuntimeClientPlugin.builder()
8182
.pluginFunction(Symbol.builder()
82-
.namespace("./" + CodegenUtils.SOURCE_FOLDER + "/middleware/HttpApiKeyAuth", "/")
83+
.namespace("./" + CodegenUtils.SOURCE_FOLDER + "/middleware/" + middlewarePath, "/")
8384
.name("getHttpApiKeyAuthPlugin")
8485
.build())
8586
.additionalPluginFunctionParamsSupplier((m, s, o) -> new HashMap<String, Object>() {{
@@ -119,7 +120,7 @@ public void writeAdditionalFiles(
119120

120121
// Write the middleware source.
121122
writerFactory.accept(
122-
Paths.get(CodegenUtils.SOURCE_FOLDER, "middleware", "HttpApiKeyAuth", "index.ts").toString(),
123+
Paths.get(CodegenUtils.SOURCE_FOLDER, "middleware", getMiddlewarePath(), "index.ts").toString(),
123124
writer -> {
124125
String source = IoUtils.readUtf8Resource(getClass(), "http-api-key-auth.ts");
125126
writer.write("$L$L", noTouchNoticePrefix, "http-api-key-auth.ts");
@@ -128,7 +129,7 @@ public void writeAdditionalFiles(
128129

129130
// Write the middleware tests.
130131
writerFactory.accept(
131-
Paths.get(CodegenUtils.SOURCE_FOLDER, "middleware", "HttpApiKeyAuth", "index.spec.ts").toString(),
132+
Paths.get(CodegenUtils.SOURCE_FOLDER, "middleware", getMiddlewarePath(), "index.spec.ts").toString(),
132133
writer -> {
133134
writer.addDependency(SymbolDependency.builder()
134135
.dependencyType("devDependencies")
@@ -142,6 +143,23 @@ public void writeAdditionalFiles(
142143
});
143144
}
144145

146+
@Override
147+
public void writeAdditionalExports(
148+
TypeScriptSettings settings,
149+
Model model,
150+
SymbolProvider symbolProvider,
151+
TypeScriptWriter writer
152+
) {
153+
boolean isClientSdk = settings.generateClient();
154+
if (isClientSdk) {
155+
writer.write("export * from \"./middleware/$1L\";", getMiddlewarePath());
156+
}
157+
}
158+
159+
private String getMiddlewarePath() {
160+
return "HttpApiKeyAuth";
161+
}
162+
145163
// The service has the effective trait if it's in the "effective auth schemes" response
146164
// AND if not all of the operations have the optional auth trait.
147165
private static boolean hasEffectiveHttpApiKeyAuthTrait(Model model, ServiceShape service) {

0 commit comments

Comments
 (0)