public static void AppendVarDataModelOrListOfModel( int indentSpaces, StringBuilder sb, EndpointMethodMetadata endpointMethodMetadata, OpenApiSchema schema, HttpStatusCode httpStatusCode, SchemaMapLocatedAreaType locatedAreaType, KeyValuePair <string, OpenApiSchema>?badPropertySchema = null, bool asJsonBody = false, int maxItemsForList = 3, int depthHierarchy = 0, int maxDepthHierarchy = 2) { ArgumentNullException.ThrowIfNull(endpointMethodMetadata); var trailingChar = TrailingCharType.SemiColon; if (asJsonBody) { trailingChar = TrailingCharType.None; } switch (locatedAreaType) { case SchemaMapLocatedAreaType.Parameter: break; case SchemaMapLocatedAreaType.RequestBody: if (schema.IsTypeArray()) { var indentSpacesForData = indentSpaces; if (asJsonBody) { sb.AppendLine(indentSpaces, "var sb = new StringBuilder();"); indentSpacesForData -= 4; } if (schema.HasItemsWithFormatTypeBinary()) { if (asJsonBody) { throw new NotSupportedException("JSON not supported when RequestBody is type Array and format type is Binary."); } sb.AppendLine(indentSpaces, "var data = GetTestFiles();"); } else { AppendVarDataEqualNewListOfModel( indentSpacesForData, sb, endpointMethodMetadata, new KeyValuePair <string, OpenApiSchema>("data", schema), trailingChar, maxItemsForList, depthHierarchy, maxDepthHierarchy, badPropertySchema, asJsonBody); } if (asJsonBody) { sb.AppendLine(indentSpaces, "var data = sb.ToString();"); } } else { if (asJsonBody) { sb.AppendLine(indentSpaces, "var sb = new StringBuilder();"); } else { GenerateXunitTestPartsHelper.AppendPartVarDataEqualNew(12, sb); } var modelName = schema.GetModelName(); AppendModel( indentSpaces, sb, endpointMethodMetadata, modelName, schema, trailingChar, 0, maxItemsForList, depthHierarchy, maxDepthHierarchy, badPropertySchema, asJsonBody); if (asJsonBody) { sb.AppendLine(indentSpaces, "var data = sb.ToString();"); } } break; case SchemaMapLocatedAreaType.Response: var contractReturnTypeName = endpointMethodMetadata.ContractReturnTypeNames.First(x => x.StatusCode == httpStatusCode); if (GenerateXunitTestPartsHelper.IsListKind(contractReturnTypeName.FullModelName)) { AppendVarDataEqualNewListOfModel( indentSpaces, sb, endpointMethodMetadata, new KeyValuePair <string, OpenApiSchema>("data", contractReturnTypeName.Schema !), trailingChar, maxItemsForList, depthHierarchy, maxDepthHierarchy, badPropertySchema, asJsonBody); } else { GenerateXunitTestPartsHelper.AppendPartVarDataEqualNew(12, sb); AppendModel( indentSpaces, sb, endpointMethodMetadata, contractReturnTypeName.FullModelName, contractReturnTypeName.Schema !, trailingChar, 0, maxItemsForList, depthHierarchy, maxDepthHierarchy, badPropertySchema, asJsonBody); } break; default: throw new ArgumentOutOfRangeException(nameof(locatedAreaType), locatedAreaType, message: null); } }