@@ -147,7 +147,8 @@ public static void setOptionalParameters(
147147 int bodyPropsOptional = 0 ;
148148 boolean actuallyHasOptional = false ;
149149 boolean isBodyTooBig = false ;
150- boolean alreadyInlinedBody = ope .allParams .size () == 1 && ope .bodyParam != null && ope .bodyParam .isModel ;
150+ boolean isBodyRequired = (ope .bodyParam != null && ope .bodyParam .required );
151+ boolean alreadyInlinedBody = ope .allParams .size () == 1 && ope .bodyParam != null && !ope .bodyParam .isArray ;
151152
152153 if (AlgoliaGoGenerator .canFlattenBody (ope )) {
153154 bodyPropsOptional = (int ) ope .bodyParam .getVars ().stream ().filter (prop -> !prop .required ).count ();
@@ -156,7 +157,14 @@ public static void setOptionalParameters(
156157 // edge case where the body is already flattened
157158 Map <String , Object > paramBody = paramBody = parameters ;
158159 if (!alreadyInlinedBody ) {
159- paramBody = (Map <String , Object >) parameters .get (ope .bodyParam .paramName );
160+ Object paramBodyObj = parameters .get (ope .bodyParam .paramName );
161+ if (paramBodyObj instanceof String ) {
162+ // this is a verbatim paramater, we use it as is
163+ System .out .println (ope .operationId + " is a verbatim body " + paramBodyObj );
164+ actuallyHasOptional = !isBodyRequired ;
165+ } else {
166+ paramBody = (Map <String , Object >) parameters .get (ope .bodyParam .paramName );
167+ }
160168 }
161169
162170 for (CodegenProperty prop : ope .bodyParam .getVars ()) {
@@ -175,8 +183,6 @@ public static void setOptionalParameters(
175183 }
176184 }
177185
178- boolean isBodyRequired = (ope .bodyParam != null && ope .bodyParam .required );
179-
180186 // I can't figure out the correct condition for this one so it's harcoded for now
181187 boolean isSFFV = ope .operationId .equals ("searchForFacetValues" ) && "composition" .equals (ope .tags .get (0 ).getName ());
182188
@@ -186,7 +192,7 @@ public static void setOptionalParameters(
186192 test .put ("hasInlineOptional" , ((totalOptional == 1 || isSFFV ) && actuallyHasOptional ) || isBodyTooBig );
187193 if (isBodyTooBig ) {
188194 boolean isBodySet = alreadyInlinedBody ? parameters .size () > 0 : parameters .containsKey (ope .bodyParam .paramName );
189- System .out .println (" isBodySet: " + isBodySet );
195+ System .out .println (ope . operationId + " isBodySet: " + isBodySet + " isBodyRequired: " + isBodyRequired );
190196 test .put ("hasNilOptional" , isBodyRequired ? totalOptional > 0 && !actuallyHasOptional : !isBodySet );
191197 } else {
192198 test .put ("hasNilOptional" , totalOptional > 0 && !actuallyHasOptional && !isHelper );
0 commit comments