internal static void AddBody(this IHttp http, IEnumerable <Parameter> parameters,
                                     IDictionary <DataFormat, IRestSerializer> serializers)
        {
            var body = parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);

            if (body == null)
            {
                return;
            }

            if (body.DataFormat == DataFormat.None)
            {
                http.AddBody(body.ContentType, body.Name, body.Value);
            }
            else
            {
                if (!serializers.TryGetValue(body.DataFormat, out var serializer))
                {
                    throw new InvalidDataContractException(
                              $"Can't find serializer for content type {body.DataFormat}");
                }

                http.AddBody(serializer.ContentType, serializer.ContentType, serializer.Serialize(body));
            }
        }
        internal static void AddBody(this IHttp http, IEnumerable <Parameter> parameters)
        {
            var body = parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);

            if (body == null)
            {
                return;
            }

            http.AddBody(body.ContentType, body.Name, body.Value);
        }
        internal static void AddBody(this IHttp http, IEnumerable <Parameter> parameters,
                                     IDictionary <DataFormat, IRestSerializer> restSerializers, params ISerializer[] serializers)
        {
            var body = parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);

            if (body == null)
            {
                return;
            }

            if (body.DataFormat == DataFormat.None)
            {
                http.AddBody(body.ContentType, body.Name, body.Value);
            }
            else
            {
                var contentType       = body.ContentType ?? ContentType.FromDataFormat[body.DataFormat];
                var requestSerializer = serializers.FirstOrDefault(x => x != null && x.ContentType == contentType);
                if (requestSerializer != null)
                {
                    http.AddBody(requestSerializer.ContentType, requestSerializer.ContentType,
                                 requestSerializer.Serialize(body.Value));
                }
                else
                {
                    IRestSerializer serializer;
                    if (!restSerializers.TryGetValue(body.DataFormat, out serializer))
                    {
                        throw new InvalidDataContractException(
                                  String.Format("Can't find serializer for content type {0}", body.DataFormat));
                    }

                    http.AddBody(serializer.ContentType, serializer.ContentType, serializer.Serialize(body));
                }
            }
        }
        internal static void AddBody(this IHttp http, BodyParameter bodyParameter,
                                     IDictionary <DataFormat, IRestSerializer> serializers)
        {
            if (bodyParameter == null)
            {
                return;
            }

            if (!serializers.TryGetValue(bodyParameter.ParameterType, out var serializer))
            {
                throw new InvalidDataContractException($"Can't find serializer for content type {bodyParameter.ParameterType}");
            }

            http.AddBody(serializer.ContentType, serializer.ContentType, serializer.Serialize(bodyParameter));
        }