@@ -147,7 +147,8 @@ public static void setOptionalParameters(
147
147
int bodyPropsOptional = 0 ;
148
148
boolean actuallyHasOptional = false ;
149
149
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 ;
151
152
152
153
if (AlgoliaGoGenerator .canFlattenBody (ope )) {
153
154
bodyPropsOptional = (int ) ope .bodyParam .getVars ().stream ().filter (prop -> !prop .required ).count ();
@@ -156,7 +157,14 @@ public static void setOptionalParameters(
156
157
// edge case where the body is already flattened
157
158
Map <String , Object > paramBody = paramBody = parameters ;
158
159
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
+ }
160
168
}
161
169
162
170
for (CodegenProperty prop : ope .bodyParam .getVars ()) {
@@ -175,8 +183,6 @@ public static void setOptionalParameters(
175
183
}
176
184
}
177
185
178
- boolean isBodyRequired = (ope .bodyParam != null && ope .bodyParam .required );
179
-
180
186
// I can't figure out the correct condition for this one so it's harcoded for now
181
187
boolean isSFFV = ope .operationId .equals ("searchForFacetValues" ) && "composition" .equals (ope .tags .get (0 ).getName ());
182
188
@@ -186,7 +192,7 @@ public static void setOptionalParameters(
186
192
test .put ("hasInlineOptional" , ((totalOptional == 1 || isSFFV ) && actuallyHasOptional ) || isBodyTooBig );
187
193
if (isBodyTooBig ) {
188
194
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 );
190
196
test .put ("hasNilOptional" , isBodyRequired ? totalOptional > 0 && !actuallyHasOptional : !isBodySet );
191
197
} else {
192
198
test .put ("hasNilOptional" , totalOptional > 0 && !actuallyHasOptional && !isHelper );
0 commit comments