public static void AppendDataEqualNewListOfModel(
            int indentSpaces,
            StringBuilder sb,
            EndpointMethodMetadata endpointMethodMetadata,
            KeyValuePair<string, OpenApiSchema> schemaProperty,
            TrailingCharType trailingChar,
            int maxItemsForList,
            int depthHierarchy,
            int maxDepthHierarchy,
            KeyValuePair<string, OpenApiSchema>? badPropertySchema,
            bool asJsonBody)
        {
            var modelName = schemaProperty.Value.GetModelName();
            var renderModelName = OpenApiDocumentSchemaModelNameHelper.EnsureModelNameWithNamespaceIfNeeded(endpointMethodMetadata, modelName);
            var propertyName = schemaProperty.Key.EnsureFirstCharacterToUpper();
            var jsonSpacesCount = (depthHierarchy * 2) + 2;

            if (depthHierarchy > maxDepthHierarchy)
            {
                if (asJsonBody)
                {
                    // TODO Missing Json support.
                }
                else
                {
                    sb.AppendLine(
                        indentSpaces,
                        $"{propertyName} = new List<{renderModelName}>()" + GenerateCodeHelper.GetTrailingChar(trailingChar));
                    return;
                }
            }

            if (asJsonBody)
            {
                var useForBadRequest = badPropertySchema != null &&
                                        schemaProperty.Key.Equals(badPropertySchema.Value.Key, StringComparison.Ordinal);

                if (useForBadRequest)
                {
                    sb.AppendLine(
                        indentSpaces - jsonSpacesCount,
                        GenerateXunitTestPartsHelper.WrapInStringBuilderAppendLineWithKeyQuotes(depthHierarchy - 1, propertyName, "null", trailingChar));
                    return;
                }

                sb.AppendLine(
                    indentSpaces - jsonSpacesCount,
                    GenerateXunitTestPartsHelper.WrapInStringBuilderAppendLineWithKeyQuotes(depthHierarchy - 1, propertyName, "[", TrailingCharType.None));
            }
            else
            {
                GenerateXunitTestPartsHelper.AppendPartDataEqualNewListOf(
                    indentSpaces,
                    sb,
                    propertyName,
                    modelName);
                sb.AppendLine();
                sb.AppendLine(indentSpaces, "{");
            }

            var modelSchema = endpointMethodMetadata.ComponentsSchemas.GetSchemaByModelName(modelName);
            var currentIndentSpaces = asJsonBody
                ? indentSpaces - jsonSpacesCount
                : indentSpaces + 4;

            for (int i = 0; i < maxItemsForList; i++)
            {
                var trailingCharForProperty = GenerateXunitTestPartsHelper.GetTrailingCharForProperty(asJsonBody, i, maxItemsForList);

                if (!asJsonBody)
                {
                    GenerateXunitTestPartsHelper.AppendPartDataNew(currentIndentSpaces, sb);
                }

                AppendModel(
                    currentIndentSpaces,
                    sb,
                    endpointMethodMetadata,
                    modelName,
                    modelSchema,
                    trailingCharForProperty,
                    i + 1,
                    maxItemsForList,
                    depthHierarchy,
                    maxDepthHierarchy,
                    badPropertySchema,
                    asJsonBody);
            }

            if (asJsonBody)
            {
                var jsonSpaces = string.Empty.PadLeft((depthHierarchy - 1) * 2);
                sb.AppendLine(
                    indentSpaces - jsonSpacesCount,
                    GenerateXunitTestPartsHelper.WrapInStringBuilderAppendLine($"{jsonSpaces}  ]{GenerateCodeHelper.GetTrailingChar(trailingChar)}"));
            }
            else
            {
                sb.AppendLine(
                    indentSpaces,
                    $"}}{GenerateCodeHelper.GetTrailingChar(trailingChar)}");
            }
        }
        public static void AppendModel(
            int indentSpaces,
            StringBuilder sb,
            EndpointMethodMetadata endpointMethodMetadata,
            string modelName,
            OpenApiSchema schema,
            TrailingCharType trailingChar,
            int itemNumber,
            int maxItemsForList,
            int depthHierarchy,
            int maxDepthHierarchy,
            KeyValuePair<string, OpenApiSchema>? badPropertySchema,
            bool asJsonBody,
            string? parentModelNameToJsonBody = null)
        {
            int countString = 1;
            var renderModelName = OpenApiDocumentSchemaModelNameHelper.EnsureModelNameWithNamespaceIfNeeded(endpointMethodMetadata, modelName);
            var jsonSpaces = string.Empty.PadLeft(depthHierarchy * 2);
            if (asJsonBody)
            {
                sb.AppendLine(
                    indentSpaces,
                    string.IsNullOrEmpty(parentModelNameToJsonBody)
                        ? GenerateXunitTestPartsHelper.WrapInStringBuilderAppendLine($"{jsonSpaces}{{")
                        : GenerateXunitTestPartsHelper.WrapInStringBuilderAppendLine($"{jsonSpaces}\\\"{parentModelNameToJsonBody}\\\": {{"));
            }
            else
            {
                sb.AppendLine(renderModelName);
                sb.AppendLine(indentSpaces, "{");
            }

            foreach (var schemaProperty in schema.Properties)
            {
                var trailingCharForProperty = GenerateXunitTestPartsHelper.GetTrailingCharForProperty(asJsonBody, schemaProperty, schema.Properties);
                var useForBadRequest = badPropertySchema != null &&
                                       schemaProperty.Key.Equals(badPropertySchema.Value.Key, StringComparison.Ordinal);

                string dataType = schemaProperty.Value.GetDataType();
                string propertyValueGenerated = GenerateXunitTestPartsHelper.PropertyValueGenerator(schemaProperty, endpointMethodMetadata.ComponentsSchemas, useForBadRequest, itemNumber, null);

                if ("NEW-INSTANCE-LIST".Equals(propertyValueGenerated, StringComparison.Ordinal))
                {
                    AppendDataEqualNewListOfModel(
                        indentSpaces + 4,
                        sb,
                        endpointMethodMetadata,
                        schemaProperty,
                        trailingCharForProperty,
                        maxItemsForList,
                        depthHierarchy + 1,
                        maxDepthHierarchy,
                        badPropertySchema,
                        asJsonBody);
                }
                else if ("NEW-INSTANCE".Equals(propertyValueGenerated, StringComparison.Ordinal))
                {
                    AppendModelComplexProperty(
                        indentSpaces,
                        sb,
                        endpointMethodMetadata,
                        schemaProperty,
                        dataType,
                        trailingCharForProperty,
                        itemNumber,
                        maxItemsForList,
                        depthHierarchy + 1,
                        maxDepthHierarchy,
                        badPropertySchema,
                        asJsonBody);
                }
                else
                {
                    var countResult = GenerateXunitTestPartsHelper.AppendModelSimpleProperty(
                        indentSpaces,
                        sb,
                        endpointMethodMetadata,
                        schemaProperty,
                        dataType,
                        propertyValueGenerated,
                        countString,
                        asJsonBody,
                        depthHierarchy,
                        trailingCharForProperty);

                    if (countResult > 1)
                    {
                        countString += 1;
                    }
                }
            }

            sb.AppendLine(
                indentSpaces,
                asJsonBody
                    ? GenerateXunitTestPartsHelper.WrapInStringBuilderAppendLine($"{jsonSpaces}}}{GenerateCodeHelper.GetTrailingChar(trailingChar)}")
                    : $"}}{GenerateCodeHelper.GetTrailingChar(trailingChar)}");
        }