@@ -143,7 +143,8 @@ public static void setOptionalParameters(
143143 int bodyPropsOptional = 0 ;
144144 boolean actuallyHasOptional = false ;
145145 boolean isBodyTooBig = false ;
146- boolean alreadyInlinedBody = ope .allParams .size () == 1 && ope .bodyParam != null && ope .bodyParam .isModel ;
146+ boolean isBodyRequired = (ope .bodyParam != null && ope .bodyParam .required );
147+ boolean alreadyInlinedBody = ope .allParams .size () == 1 && ope .bodyParam != null && !ope .bodyParam .isArray ;
147148
148149 if (AlgoliaGoGenerator .canFlattenBody (ope )) {
149150 bodyPropsOptional = (int ) ope .bodyParam .getVars ().stream ().filter (prop -> !prop .required ).count ();
@@ -152,7 +153,14 @@ public static void setOptionalParameters(
152153 // edge case where the body is already flattened
153154 Map <String , Object > paramBody = paramBody = parameters ;
154155 if (!alreadyInlinedBody ) {
155- paramBody = (Map <String , Object >) parameters .get (ope .bodyParam .paramName );
156+ Object paramBodyObj = parameters .get (ope .bodyParam .paramName );
157+ if (paramBodyObj instanceof String ) {
158+ // this is a verbatim paramater, we use it as is
159+ System .out .println (ope .operationId + " is a verbatim body " + paramBodyObj );
160+ actuallyHasOptional = !isBodyRequired ;
161+ } else {
162+ paramBody = (Map <String , Object >) parameters .get (ope .bodyParam .paramName );
163+ }
156164 }
157165
158166 for (CodegenProperty prop : ope .bodyParam .getVars ()) {
@@ -171,8 +179,6 @@ public static void setOptionalParameters(
171179 }
172180 }
173181
174- boolean isBodyRequired = (ope .bodyParam != null && ope .bodyParam .required );
175-
176182 // I can't figure out the correct condition for this one so it's harcoded for now
177183 boolean isSFFV = ope .operationId .equals ("searchForFacetValues" ) && "composition" .equals (ope .tags .get (0 ).getName ());
178184
@@ -182,7 +188,7 @@ public static void setOptionalParameters(
182188 test .put ("hasInlineOptional" , ((totalOptional == 1 || isSFFV ) && actuallyHasOptional ) || isBodyTooBig );
183189 if (isBodyTooBig ) {
184190 boolean isBodySet = alreadyInlinedBody ? parameters .size () > 0 : parameters .containsKey (ope .bodyParam .paramName );
185- System .out .println (" isBodySet: " + isBodySet );
191+ System .out .println (ope . operationId + " isBodySet: " + isBodySet + " isBodyRequired: " + isBodyRequired );
186192 test .put ("hasNilOptional" , isBodyRequired ? totalOptional > 0 && !actuallyHasOptional : !isBodySet );
187193 } else {
188194 test .put ("hasNilOptional" , totalOptional > 0 && !actuallyHasOptional && !isHelper );
0 commit comments