private MetadataParameter[] GetRequestParameters(MethodInfo method)
        {
            var parameters = new List <MetadataParameter>();

            // add common parameters
            var actionAttribute = method.GetCustomAttributes(typeof(ActionAttribute), true).Cast <ActionAttribute>().First();

            parameters.Add(new MetadataParameter("action", _helper.ToJsonType(typeof(string)), "Action name: " + actionAttribute.ActionName, true));
            parameters.Add(new MetadataParameter("requestId", _helper.ToJsonType(typeof(object)), "Request unique identifier, will be passed back in the response message.", false));

            // add device authentication parameters
            if (IsDeviceMethod(method))
            {
                if (GetAuthorization(method) == "Device")
                {
                    parameters.Add(new MetadataParameter("deviceId", _helper.ToJsonType(typeof(string)), "Device unique identifier (specify if not authenticated).", false));
                    parameters.Add(new MetadataParameter("deviceKey", _helper.ToJsonType(typeof(string)), "Device authentication key (specify if not authenticated).", false));
                }
            }

            // add action method parameters
            foreach (var p in method.GetParameters())
            {
                var methodParamElement = _wsXmlCommentReader.GetMethodParameterElement(method, p.Name);
                parameters.Add(new MetadataParameter
                {
                    Name          = p.Name,
                    Type          = _helper.ToJsonType(p.ParameterType),
                    Documentation = methodParamElement == null ? null : methodParamElement.Contents(),
                    IsRequred     = !p.IsOptional && !(p.ParameterType.IsGenericType &&
                                                       p.ParameterType.GetGenericTypeDefinition() == typeof(Nullable <>)),
                });

                if (methodParamElement != null && typeof(JToken).IsAssignableFrom(p.ParameterType))
                {
                    var resourceType = _helper.GetCrefType(methodParamElement);
                    if (resourceType != null)
                    {
                        parameters.AddRange(_helper.GetTypeParameters(resourceType, JsonMapperEntryMode.FromJson, prefix: p.Name + "."));
                    }
                }
            }

            // adjust parameters according to the XML request element
            var methodElement  = _wsXmlCommentReader.GetMethodElement(method);
            var requestElement = methodElement == null ? null : methodElement.Element("request");

            if (requestElement != null)
            {
                _helper.AdjustParameters(parameters, requestElement, JsonMapperEntryMode.FromJson);
            }

            // adjust documentation for device/save method
            if (IsDeviceMethod(method) && actionAttribute.ActionName == "device/save")
            {
                parameters.Insert(3, new MetadataParameter("deviceKey", _helper.ToJsonType(typeof(string)), "Device authentication key.", true));
            }


            return(parameters.ToArray());
        }