private static void AppendTest400BadRequestInBody(
        StringBuilder sb,
        EndpointMethodMetadata endpointMethodMetadata,
        ResponseTypeNameAndItemSchema contractReturnTypeName)
    {
        if (!endpointMethodMetadata.HasContractParameterRequestBody())
        {
            return;
        }

        if (endpointMethodMetadata.IsContractParameterRequestBodyUsedAsMultipartFormData())
        {
            return;
        }

        var schema = endpointMethodMetadata.ContractParameter?.ApiOperation.RequestBody?.Content.GetSchemaByFirstMediaType();

        if (schema is null)
        {
            return;
        }

        var modelName = schema.GetModelName();

        if (string.IsNullOrEmpty(modelName))
        {
            return;
        }

        var modelSchema     = endpointMethodMetadata.ComponentsSchemas.GetSchemaByModelName(modelName);
        var relevantSchemas = endpointMethodMetadata.GetRelevantSchemasForBadRequestBodyParameters(modelSchema);

        var headerRequiredParameters = endpointMethodMetadata.GetHeaderRequiredParameters();

        var relativeRef = RenderRelativeRef(endpointMethodMetadata);

        foreach (var testForSchema in relevantSchemas)
        {
            sb.AppendLine();
            sb.AppendLine(8, "[Theory]");
            sb.AppendLine(8, $"[InlineData(\"{relativeRef}\")]");
            sb.AppendLine(8, $"public async Task {endpointMethodMetadata.MethodName}_BadRequest_InBody_{testForSchema.Key.EnsureFirstCharacterToUpper()}(string relativeRef)");
            sb.AppendLine(8, "{");
            sb.AppendLine(12, "// Arrange");
            if (headerRequiredParameters.Count > 0)
            {
                foreach (var headerParameter in headerRequiredParameters)
                {
                    var propertyValueGenerated = PropertyValueGenerator(headerParameter, endpointMethodMetadata.ComponentsSchemas, useForBadRequest: false, customValue: null);
                    sb.AppendLine(
                        12,
                        $"HttpClient.DefaultRequestHeaders.Add(\"{headerParameter.Name}\", \"{propertyValueGenerated}\");");
                }

                sb.AppendLine();
            }

            AppendNewRequestModelForBadRequest(12, sb, endpointMethodMetadata, contractReturnTypeName.StatusCode, testForSchema);
            sb.AppendLine();
            AppendActHttpClientOperation(12, sb, endpointMethodMetadata.HttpOperation, useData: true, isDataJson: true);
            sb.AppendLine();
            sb.AppendLine(12, "// Assert");
            sb.AppendLine(12, "response.Should().NotBeNull();");
            sb.AppendLine(12, $"response.StatusCode.Should().Be(HttpStatusCode.{HttpStatusCode.BadRequest});");
            sb.AppendLine(8, "}");
        }
    }