@@ -106,6 +106,9 @@ public class JavaClientCodegen extends AbstractJavaCodegen
106
106
protected String authFolder ;
107
107
protected String serializationLibrary = null ;
108
108
109
+ protected boolean addOAuthSupportingFiles = false ;
110
+ protected boolean addOAuthRetrySupportingFiles = false ;
111
+
109
112
public JavaClientCodegen () {
110
113
super ();
111
114
@@ -368,7 +371,7 @@ public void processOpts() {
368
371
supportingFiles .add (new SupportingFile ("ProgressResponseBody.mustache" , invokerFolder , "ProgressResponseBody.java" ));
369
372
supportingFiles .add (new SupportingFile ("GzipRequestInterceptor.mustache" , invokerFolder , "GzipRequestInterceptor.java" ));
370
373
371
- // NOTE: below moved to postProcessOpoerationsWithModels
374
+ // NOTE: below moved to postProcessOperationsWithModels
372
375
//supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
373
376
//supportingFiles.add(new SupportingFile("auth/RetryingOAuth.mustache", authFolder, "RetryingOAuth.java"));
374
377
forceSerializationLibrary (SERIALIZATION_LIBRARY_GSON );
@@ -588,16 +591,22 @@ public int compare(CodegenParameter one, CodegenParameter another) {
588
591
}
589
592
}
590
593
591
- // for okhttp-gson (default), check to see if OAuth is defined and included OAuth-related files accordingly
592
- if ((OKHTTP_GSON .equals (getLibrary ()) || StringUtils .isEmpty (getLibrary ())) && ProcessUtils .hasOAuthMethods (objs )) {
593
- supportingFiles .add (new SupportingFile ("auth/OAuthOkHttpClient.mustache" , authFolder , "OAuthOkHttpClient.java" ));
594
- supportingFiles .add (new SupportingFile ("auth/RetryingOAuth.mustache" , authFolder , "RetryingOAuth.java" ));
595
- }
594
+ // has OAuth defined
595
+ if (ProcessUtils .hasOAuthMethods (objs )) {
596
+ // for okhttp-gson (default), check to see if OAuth is defined and included OAuth-related files accordingly
597
+ if ((OKHTTP_GSON .equals (getLibrary ()) || StringUtils .isEmpty (getLibrary ())) && !addOAuthRetrySupportingFiles ) {
598
+ supportingFiles .add (new SupportingFile ("auth/OAuthOkHttpClient.mustache" , authFolder , "OAuthOkHttpClient.java" ));
599
+ supportingFiles .add (new SupportingFile ("auth/RetryingOAuth.mustache" , authFolder , "RetryingOAuth.java" ));
600
+ addOAuthRetrySupportingFiles = true ; // add only once
601
+ }
596
602
597
- // google-api-client doesn't use the OpenAPI auth, because it uses Google Credential directly (HttpRequestInitializer)
598
- if ((!(GOOGLE_API_CLIENT .equals (getLibrary ()) || REST_ASSURED .equals (getLibrary ()) || usePlayWS || NATIVE .equals (getLibrary ()) || MICROPROFILE .equals (getLibrary ()))) && ProcessUtils .hasOAuthMethods (objs )) {
599
- supportingFiles .add (new SupportingFile ("auth/OAuth.mustache" , authFolder , "OAuth.java" ));
600
- supportingFiles .add (new SupportingFile ("auth/OAuthFlow.mustache" , authFolder , "OAuthFlow.java" ));
603
+ // google-api-client doesn't use the OpenAPI auth, because it uses Google Credential directly (HttpRequestInitializer)
604
+ if (!(GOOGLE_API_CLIENT .equals (getLibrary ()) || REST_ASSURED .equals (getLibrary ()) || usePlayWS
605
+ || NATIVE .equals (getLibrary ()) || MICROPROFILE .equals (getLibrary ())) && !addOAuthSupportingFiles ) {
606
+ supportingFiles .add (new SupportingFile ("auth/OAuth.mustache" , authFolder , "OAuth.java" ));
607
+ supportingFiles .add (new SupportingFile ("auth/OAuthFlow.mustache" , authFolder , "OAuthFlow.java" ));
608
+ addOAuthSupportingFiles = true ; // add only once
609
+ }
601
610
}
602
611
603
612
if (MICROPROFILE .equals (getLibrary ())) {
0 commit comments