@@ -58,19 +58,20 @@ public final class AddHttpApiKeyAuthPlugin implements TypeScriptIntegration {
58
58
*/
59
59
@ Override
60
60
public List <RuntimeClientPlugin > getClientPlugins () {
61
+ String middlewarePath = getMiddlewarePath ();
61
62
return ListUtils .of (
62
63
// Add the config if the service uses HTTP API key authorization.
63
64
RuntimeClientPlugin .builder ()
64
65
.inputConfig (Symbol .builder ()
65
- .namespace ("./" + CodegenUtils .SOURCE_FOLDER + "/middleware/HttpApiKeyAuth" , "/" )
66
+ .namespace ("./" + CodegenUtils .SOURCE_FOLDER + "/middleware/" + middlewarePath , "/" )
66
67
.name ("HttpApiKeyAuthInputConfig" )
67
68
.build ())
68
69
.resolvedConfig (Symbol .builder ()
69
- .namespace ("./" + CodegenUtils .SOURCE_FOLDER + "/middleware/HttpApiKeyAuth" , "/" )
70
+ .namespace ("./" + CodegenUtils .SOURCE_FOLDER + "/middleware/" + middlewarePath , "/" )
70
71
.name ("HttpApiKeyAuthResolvedConfig" )
71
72
.build ())
72
73
.resolveFunction (Symbol .builder ()
73
- .namespace ("./" + CodegenUtils .SOURCE_FOLDER + "/middleware/HttpApiKeyAuth" , "/" )
74
+ .namespace ("./" + CodegenUtils .SOURCE_FOLDER + "/middleware/" + middlewarePath , "/" )
74
75
.name ("resolveHttpApiKeyAuthConfig" )
75
76
.build ())
76
77
.servicePredicate ((m , s ) -> hasEffectiveHttpApiKeyAuthTrait (m , s ))
@@ -79,7 +80,7 @@ public List<RuntimeClientPlugin> getClientPlugins() {
79
80
// Add the middleware to operations that use HTTP API key authorization.
80
81
RuntimeClientPlugin .builder ()
81
82
.pluginFunction (Symbol .builder ()
82
- .namespace ("./" + CodegenUtils .SOURCE_FOLDER + "/middleware/HttpApiKeyAuth" , "/" )
83
+ .namespace ("./" + CodegenUtils .SOURCE_FOLDER + "/middleware/" + middlewarePath , "/" )
83
84
.name ("getHttpApiKeyAuthPlugin" )
84
85
.build ())
85
86
.additionalPluginFunctionParamsSupplier ((m , s , o ) -> new HashMap <String , Object >() {{
@@ -119,7 +120,7 @@ public void writeAdditionalFiles(
119
120
120
121
// Write the middleware source.
121
122
writerFactory .accept (
122
- Paths .get (CodegenUtils .SOURCE_FOLDER , "middleware" , "HttpApiKeyAuth" , "index.ts" ).toString (),
123
+ Paths .get (CodegenUtils .SOURCE_FOLDER , "middleware" , getMiddlewarePath () , "index.ts" ).toString (),
123
124
writer -> {
124
125
String source = IoUtils .readUtf8Resource (getClass (), "http-api-key-auth.ts" );
125
126
writer .write ("$L$L" , noTouchNoticePrefix , "http-api-key-auth.ts" );
@@ -128,7 +129,7 @@ public void writeAdditionalFiles(
128
129
129
130
// Write the middleware tests.
130
131
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 (),
132
133
writer -> {
133
134
writer .addDependency (SymbolDependency .builder ()
134
135
.dependencyType ("devDependencies" )
@@ -142,6 +143,23 @@ public void writeAdditionalFiles(
142
143
});
143
144
}
144
145
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
+
145
163
// The service has the effective trait if it's in the "effective auth schemes" response
146
164
// AND if not all of the operations have the optional auth trait.
147
165
private static boolean hasEffectiveHttpApiKeyAuthTrait (Model model , ServiceShape service ) {
0 commit comments