@@ -98,16 +98,19 @@ public static ModelAuthSchemeKnowledgeIndex of(IntermediateModel intermediateMod
9898 */
9999 public Map <List <String >, List <AuthSchemeCodegenMetadata >> operationsToMetadata () {
100100
101- Set <String > chunkedEncodingOps = operationsShouldUseChunkedEncoding ();
101+ Set <String > allChunkedOps = operationsShouldUseChunkedEncoding ();
102102 List <AuthSchemeCodegenMetadata > serviceDefaults = serviceDefaultAuthSchemeCodeGenMetadata ();
103103
104104 Map <List <String >, List <AuthSchemeCodegenMetadata >> result = new LinkedHashMap <>();
105- Set <String > processedChunkedOps = new HashSet <>();
105+ Set <String > chunkedOpsWithAuthTrait = new HashSet <>();
106106
107- processOperationsWithAuthTraits (chunkedEncodingOps , serviceDefaults , result , processedChunkedOps );
107+ // Add metadata for all operations with auth traits. If an operation also supports chunked encoding, merge chunked
108+ // encoding trait with the defined auth traits
109+ processAllOperationsWithAuthTraits (allChunkedOps , serviceDefaults , result , chunkedOpsWithAuthTrait );
108110
109- // Handle chunked encoding operations that use service defaults
110- processRemainingChunkedEncodingOperations (result , chunkedEncodingOps , processedChunkedOps , serviceDefaults );
111+ // Add metadata for remaining chunked encoding operations (chunked encoding operations without auth trait) by merging
112+ // chunked encoding trait with service defaults
113+ processChunkedEncodingOperationsWithoutAuthTraits (result , allChunkedOps , chunkedOpsWithAuthTrait , serviceDefaults );
111114
112115 // Add service-wide defaults
113116 result .put (Collections .emptyList (), serviceDefaults );
@@ -170,8 +173,6 @@ private Map<List<String>, List<AuthTrait>> operationsToAuthOptions() {
170173 }
171174
172175 /**
173- * Determines if an operation should be included based on whether it has auth traits.
174- *
175176 * <p>Returns false if:
176177 * <ul>
177178 * <li>The operation has no modeled auth traits (empty auth list)</li>
@@ -201,22 +202,22 @@ private boolean hasAuthTrait(Map.Entry<String, OperationModel> op) {
201202 String .format ("Operation %s has auth trait and requires special handling: " , op .getKey ()));
202203 }
203204
204- private void processOperationsWithAuthTraits (Set <String > chunkedEncodingOps ,
205- List <AuthSchemeCodegenMetadata > serviceDefaults ,
206- Map <List <String >, List <AuthSchemeCodegenMetadata >> result ,
207- Set <String > processedChunkedOps ) {
205+ private void processAllOperationsWithAuthTraits (Set <String > allChunkedEncodingOps ,
206+ List <AuthSchemeCodegenMetadata > serviceDefaults ,
207+ Map <List <String >, List <AuthSchemeCodegenMetadata >> result ,
208+ Set <String > chunkedEncodingOpsWithAuthTrait ) {
208209 Map <List <String >, List <AuthTrait >> operationsToAuthOption = operationsToAuthOptions ();
209210 for (Map .Entry <List <String >, List <AuthTrait >> entry : operationsToAuthOption .entrySet ()) {
210211 List <String > allOperations = entry .getKey ();
211212 List <AuthTrait > authTraits = entry .getValue ();
212213
213- // Split operations into regular and chunked encoding
214+ // Split operations with auth trait into regular and chunked encoding
214215 List <String > regularOps = new ArrayList <>();
215216 List <String > chunkedOps = new ArrayList <>();
216217 for (String op : allOperations ) {
217- if (chunkedEncodingOps .contains (op )) {
218+ if (allChunkedEncodingOps .contains (op )) {
218219 chunkedOps .add (op );
219- processedChunkedOps .add (op );
220+ chunkedEncodingOpsWithAuthTrait .add (op );
220221 } else {
221222 regularOps .add (op );
222223 }
@@ -253,14 +254,14 @@ private boolean hasCustomServiceAuthSchemeOverride() {
253254 return false ;
254255 }
255256
256- private void processRemainingChunkedEncodingOperations (Map <List <String >, List <AuthSchemeCodegenMetadata >> result ,
257- Set <String > allChunkedOps ,
258- Set <String > processedChunkedOps ,
259- List <AuthSchemeCodegenMetadata > serviceDefaults ) {
260- Set <String > unprocessedOps = new HashSet <>(allChunkedOps );
261- unprocessedOps .removeAll (processedChunkedOps );
262- if (!unprocessedOps .isEmpty ()) {
263- result .put (new ArrayList <>(unprocessedOps ), addChunkedEncodingEnabledProperty (serviceDefaults ));
257+ private void processChunkedEncodingOperationsWithoutAuthTraits (Map <List <String >, List <AuthSchemeCodegenMetadata >> result ,
258+ Set <String > allChunkedOps ,
259+ Set <String > chunkedOpsWithAuthTrait ,
260+ List <AuthSchemeCodegenMetadata > serviceDefaults ) {
261+ Set <String > remainingChunkedOps = new HashSet <>(allChunkedOps );
262+ remainingChunkedOps .removeAll (chunkedOpsWithAuthTrait );
263+ if (!remainingChunkedOps .isEmpty ()) {
264+ result .put (new ArrayList <>(remainingChunkedOps ), addChunkedEncodingEnabledProperty (serviceDefaults ));
264265 }
265266 }
266267
0 commit comments