public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetdata)
        {
            var exclusions = new List<string> {"ToString", "GetType", "GetHashCode", "Equals"};
            var allowedVerbs = new List<string> {"GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS"};

            if (exclusions.Contains(publicMethod.Name))
            {
                return false;
            }

            var nameUpper = publicMethod.Name.ToUpper();

            var methodAttribute = HttpOperationAttribute.Find(publicMethod);
            if (methodAttribute != null)
            {
                methodMetdata.HttpVerb = methodAttribute.Method;
                return true;
            }

            if (allowedVerbs.Contains(nameUpper))
            {
                methodMetdata.HttpVerb = nameUpper;
                return true;
            }

            foreach (var verb in allowedVerbs.Where(nameUpper.StartsWith))
            {
                methodMetdata.HttpVerb = verb;
                return true;
            }

            return false;
        }
Example #2
0
        public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetdata)
        {
            methodMetdata.InputParameters = publicMethod.GetParameters().Select(param => new InputParameter
            {
                Name = param.Name,
                Type = param.ParameterType
            }).ToList();

            foreach (var param in methodMetdata.InputParameters)
            {
                param.LocationType = InputParameter.LocationTypes.Query;

                if (methodMetdata.UriParser.HasParam(param.Name))
                {
                    param.LocationType = methodMetdata.UriParser.HasPathParam(param.Name)
                        ? InputParameter.LocationTypes.Path
                        : InputParameter.LocationTypes.Query;

                    if (!param.Type.IsPrimitive)
                    {
                        param.Type = typeof(string);
                    }
                }

                if (!TypeMapper.IsTypeSwaggerPrimitive(param.Type))
                {
                    param.LocationType = InputParameter.LocationTypes.Body;
                }
            }

            return(true);
        }
Example #3
0
 public void SetUp()
 {
     _sut      = new DiscoverHttpMethodVerbs();
     _metadata = new OperationMetadata(new UriModel {
         Uri = "/some/uri"
     });
 }
        public OperationGroup Group(ResourceModel resourceModel, UriModel uriModel, OperationMetadata operation)
        {
            if (IsUnknownReturnType(operation.ReturnType))
            {
                return(new OperationGroup {
                    Name = "Unknown", Path = "unknown"
                });
            }

            if (IsEnumerableButNotAString(operation))
            {
                var collectionType = operation.ReturnType.GetElementType();
                if (operation.ReturnType.IsGenericType)
                {
                    collectionType = operation.ReturnType.GetGenericArguments()[0];
                }

                return(new OperationGroup
                {
                    Name = "Collection of " + collectionType.Name,
                    Path = collectionType.Name.ToLower() + "[]"
                });
            }

            return(new OperationGroup {
                Name = operation.ReturnType.Name, Path = operation.ReturnType.Name.ToLower()
            });
        }
        private OperationMetadata GetNodeForReadOperation(OperationMetadata node)
        {
            Debug.Assert(node != null);

            var nodes = new List <OperationMetadata>(NodeUrls);

            if (readStripingBase == -1)
            {
                return(LeaderNode);
            }

            if (nodes.Count == 0)
            {
                return(null);
            }


            var nodeIndex = readStripingBase % nodes.Count;
            var readNode  = nodes[nodeIndex];

            if (ShouldExecuteUsing(readNode))
            {
                return(readNode);
            }

            return(node);
        }
Example #6
0
 public SingleAuthTokenRetriever(IHoldProfilingInformation profilingInfo, ConventionBase convention, NameValueCollection operationHeaders, OperationMetadata operationMetadata)
 {
     this.profilingInfo     = profilingInfo;
     this.convention        = convention;
     this.operationHeaders  = operationHeaders;
     this.operationMetadata = operationMetadata;
 }
Example #7
0
        public void TestContentTypeOverride()
        {
            RequestMap        requestMap  = new RequestMap("{\n\"id\":\"1\"\n}");
            RequestMap        responseMap = new RequestMap("{\"Account\":{\"Status\":\"true\",\"Listed\":\"true\",\"ReasonCode\":\"S\",\"Reason\":\"STOLEN\"}}");
            TestApiController controller  = new TestApiController();

            controller.SetRestClient(mockClient(HttpStatusCode.OK, responseMap));

            // new Tuple<string, string, List<string>, List<string>>("/test1", null, headerList, queryList);
            var config   = new OperationConfig("/test1", "create", headerList, queryList);
            var metadata = new OperationMetadata("0.0.1", "http://locahost:8081", null, true, "text/json");

            RestyRequest request = controller.GetRequest(config, metadata, new TestBaseObject(requestMap));

            Assert.AreEqual("http://locahost:8081/test1", request.AbsoluteUrl.ToString());
            Assert.AreEqual(true, request.HasBody);
            Assert.AreEqual("POST", request.Method.ToString());
            Assert.AreEqual(true, request.Parameters.Exists(i => i.Name.Equals("Content-Type")));
            Assert.AreEqual(true, request.Parameters.Exists(i => i.Name.Equals("Content-Type")));

            Assert.AreEqual("text/json; charset=utf-8", request.Parameters.Find(i => i.Name.Equals("Accept")).Value.ToString());
            Assert.AreEqual("text/json; charset=utf-8", request.Parameters.Find(i => i.Name.Equals("Content-Type")).Value.ToString());



            String authentication = request.Parameters.Find(i => i.Name.Equals("Authorization")).Value.ToString();

            Assert.AreEqual(true, authentication.Contains("oauth_body_hash"));
        }
Example #8
0
        public void MergeFrom(OfflineUserDataJob other)
        {
            if (other == null)
            {
                return;
            }
            if (other.ResourceName.Length != 0)
            {
                ResourceName = other.ResourceName;
            }
            if (other.HasId)
            {
                Id = other.Id;
            }
            if (other.HasExternalId)
            {
                ExternalId = other.ExternalId;
            }
            if (other.Type != global::Google.Ads.GoogleAds.V10.Enums.OfflineUserDataJobTypeEnum.Types.OfflineUserDataJobType.Unspecified)
            {
                Type = other.Type;
            }
            if (other.Status != global::Google.Ads.GoogleAds.V10.Enums.OfflineUserDataJobStatusEnum.Types.OfflineUserDataJobStatus.Unspecified)
            {
                Status = other.Status;
            }
            if (other.FailureReason != global::Google.Ads.GoogleAds.V10.Enums.OfflineUserDataJobFailureReasonEnum.Types.OfflineUserDataJobFailureReason.Unspecified)
            {
                FailureReason = other.FailureReason;
            }
            if (other.operationMetadata_ != null)
            {
                if (operationMetadata_ == null)
                {
                    OperationMetadata = new global::Google.Ads.GoogleAds.V10.Resources.OfflineUserDataJobMetadata();
                }
                OperationMetadata.MergeFrom(other.OperationMetadata);
            }
            switch (other.MetadataCase)
            {
            case MetadataOneofCase.CustomerMatchUserListMetadata:
                if (CustomerMatchUserListMetadata == null)
                {
                    CustomerMatchUserListMetadata = new global::Google.Ads.GoogleAds.V10.Common.CustomerMatchUserListMetadata();
                }
                CustomerMatchUserListMetadata.MergeFrom(other.CustomerMatchUserListMetadata);
                break;

            case MetadataOneofCase.StoreSalesMetadata:
                if (StoreSalesMetadata == null)
                {
                    StoreSalesMetadata = new global::Google.Ads.GoogleAds.V10.Common.StoreSalesMetadata();
                }
                StoreSalesMetadata.MergeFrom(other.StoreSalesMetadata);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }
        public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetadata)
        {
            var notes = publicMethod.GetCustomAttribute<NotesAttribute>() ?? new NotesAttribute("");
            methodMetadata.Notes = notes.Notes;
            methodMetadata.Notes += "Uri template " + methodMetadata.Uri.Uri;

            return true;
        }
Example #10
0
 public SingleAuthTokenRetriever(IHoldProfilingInformation profilingInfo, HttpJsonRequestFactory factory, Convention convention, NameValueCollection operationHeaders, OperationMetadata operationMetadata)
 {
     this.profilingInfo     = profilingInfo;
     this.factory           = factory;
     this.convention        = convention;
     this.operationHeaders  = operationHeaders;
     this.operationMetadata = operationMetadata;
 }
        private bool ShouldExecuteUsing(OperationMetadata operationMetadata)
        {
            var failureCounter = FailureCounters.GetHolder(operationMetadata.Url);
            if (failureCounter.Value <= 1) // can fail once
                return true;

            return false;
        }
Example #12
0
        public void SetUp()
        {
            _sut = new DiscoverReturnType();

            _metadata = new OperationMetadata(new UriModel {
                Uri = "/some/uri"
            });
        }
        public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetadata)
        {
            var notes = publicMethod.GetCustomAttribute <NotesAttribute>() ?? new NotesAttribute("");

            methodMetadata.Notes  = notes.Notes;
            methodMetadata.Notes += "Uri template " + methodMetadata.Uri.Uri;

            return(true);
        }
        public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetdata)
        {
            methodMetdata.InputParameters = publicMethod.GetParameters().Select(param => new InputParameter
            {
                Name = param.Name,
                Type = param.ParameterType
            }).ToList();

            /*
             * If the OpenRasta configured parameters don't match the method
             * then this isn't the correct method to match
             */
            var methodParameters = methodMetdata.InputParameters.Select(q => q.Name.ToLowerInvariant()).ToArray();
            var uriParameters    = methodMetdata.UriParser.Parameters.Select(q => q.ToLowerInvariant()).ToArray();

            if (uriParameters.Except(methodParameters).Any())
            {
                return(false);
            }

            foreach (var param in methodMetdata.InputParameters)
            {
                param.LocationType = InputParameter.LocationTypes.Query;

                if (methodMetdata.UriParser.HasParam(param.Name))
                {
                    param.LocationType = methodMetdata.UriParser.HasPathParam(param.Name)
                        ? InputParameter.LocationTypes.Path
                        : InputParameter.LocationTypes.Query;

                    if (!param.Type.IsPrimitive)
                    {
                        param.Type = typeof(string);
                    }
                }

                if (!TypeMapper.IsTypeSwaggerPrimitive(param.Type))
                {
                    param.LocationType = InputParameter.LocationTypes.Body;
                }
            }

            var requiredHeaders = publicMethod.GetCustomAttributes <RequestHeaderAttribute>();

            foreach (var header in requiredHeaders)
            {
                methodMetdata.InputParameters.Add(new InputParameter
                {
                    Name         = header.Name,
                    Type         = header.Type,
                    LocationType = InputParameter.LocationTypes.Header,
                    IsRequired   = header.IsRequired
                });
            }

            return(true);
        }
        public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetdata)
        {
            var responseType = publicMethod.GetCustomAttribute<ResponseTypeIsAttribute>() ??
                               new ResponseTypeIsAttribute(publicMethod.ReturnType);
            methodMetdata.ReturnType = responseType.ResponseType;
            methodMetdata.HandlerType = publicMethod.DeclaringType;

            return IsTypeMatch(methodMetdata.DesiredReturnType, methodMetdata.ReturnType);
        }
        public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetdata)
        {
            methodMetdata.InputParameters = publicMethod.GetParameters().Select(param => new InputParameter
            {
                Name = param.Name,
                Type = param.ParameterType

            }).ToList();

            /*
             * If the OpenRasta configured parameters don't match the method
             * then this isn't the correct method to match
             */
            var methodParameters = methodMetdata.InputParameters.Select(q => q.Name.ToLowerInvariant()).ToArray();
            var uriParameters = methodMetdata.UriParser.Parameters.Select(q => q.ToLowerInvariant()).ToArray();
            if (uriParameters.Except(methodParameters).Any())
            {
                return false;
            }

            foreach (var param in methodMetdata.InputParameters)
            {
                param.LocationType = InputParameter.LocationTypes.Query;

                if (methodMetdata.UriParser.HasParam(param.Name))
                {
                    param.LocationType = methodMetdata.UriParser.HasPathParam(param.Name)
                        ? InputParameter.LocationTypes.Path
                        : InputParameter.LocationTypes.Query;

                    if (!param.Type.IsPrimitive)
                    {
                        param.Type = typeof(string);
                    }
                }

                if (!TypeMapper.IsTypeSwaggerPrimitive(param.Type))
                {
                    param.LocationType =  InputParameter.LocationTypes.Body;
                }
            }

            var requiredHeaders = publicMethod.GetCustomAttributes<RequestHeaderAttribute>();
            foreach (var header in requiredHeaders)
            {
                methodMetdata.InputParameters.Add(new InputParameter
                {
                    Name = header.Name,
                    Type = header.Type,
                    LocationType = InputParameter.LocationTypes.Header,
                    IsRequired = header.IsRequired
                });
            }

            return true;
        }
        public void SetUp()
        {
            _sut = new DiscoverReturnType();

            _returnType = new Mock <IMember>();

            _metadata = new OperationMetadata(new UriModel {
                Uri = "/some/uri"
            }, _returnType.Object);
        }
        private HttpJsonRequest CreateRequestParams(OperationMetadata operationMetadata, string requestUrl, HttpMethod method, bool disableRequestCompression = false, bool disableAuthentication = false)
        {
            var createHttpJsonRequestParams = new CreateHttpJsonRequestParams(profilingInfo, operationMetadata.Url + requestUrl, method, operationMetadata.Credentials, convention)
                                              .AddOperationHeaders(operationHeaders);

            createHttpJsonRequestParams.DisableRequestCompression = disableRequestCompression;
            createHttpJsonRequestParams.DisableAuthentication     = disableAuthentication;

            return(factory.CreateHttpJsonRequest(createHttpJsonRequestParams));
        }
        public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetdata)
        {
            var responseType = publicMethod.GetCustomAttribute <ResponseTypeIsAttribute>() ??
                               new ResponseTypeIsAttribute(publicMethod.ReturnType);

            methodMetdata.ReturnType  = responseType.ResponseType;
            methodMetdata.HandlerType = publicMethod.DeclaringType;

            return(true);
        }
Example #20
0
        private HttpJsonRequest CreateRequestParams(OperationMetadata operationMetadata, string requestUrl, string method, bool disableRequestCompression = false, bool disableAuthentication = false, TimeSpan?timeout = null)
        {
            var metadata = new RavenJObject();
            var createHttpJsonRequestParams = new CreateHttpJsonRequestParams(profilingInfo, operationMetadata.Url + requestUrl, method, metadata, operationMetadata.Credentials, convention, timeout)
                                              .AddOperationHeaders(operationHeaders);

            createHttpJsonRequestParams.DisableRequestCompression = disableRequestCompression;
            createHttpJsonRequestParams.DisableAuthentication     = disableAuthentication;

            return(factory.CreateHttpJsonRequest(createHttpJsonRequestParams));
        }
        public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetadata)
        {
            var attribute = publicMethod.GetCustomAttribute<NotesAttribute>() ?? new NotesAttribute("");

            if(string.IsNullOrEmpty(attribute.Notes))
                methodMetadata.Notes += "Uri template " + methodMetadata.Uri.Uri;
            else
                methodMetadata.Notes = attribute.Notes;

            return true;
        }
        public void NamesMatchCorrectly()
        {
            var method1  = typeof(SampleHandler).GetMethod("NameTest1");
            var method2  = typeof(SampleHandler).GetMethod("NameTest2");
            var metadata = new OperationMetadata(new UriModel {
                Uri = "/some/uri", Name = "NameTest1"
            }, null);

            Assert.IsTrue(_sut.Discover(method1, metadata));
            Assert.IsFalse(_sut.Discover(method2, metadata));
        }
Example #23
0
        public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetdata)
        {
            var descriptionAttribute = publicMethod.GetCustomAttribute <DescriptionAttribute>();

            methodMetdata.Nickname = publicMethod.Name;
            methodMetdata.Summary  = descriptionAttribute == null
                ? GetMethodName(publicMethod)
                : descriptionAttribute.Description;

            return(true);
        }
        public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetdata)
        {
            var descriptionAttribute = publicMethod.GetCustomAttribute<DescriptionAttribute>();

            methodMetdata.Nickname = publicMethod.Name;
            methodMetdata.Summary = descriptionAttribute == null 
                ? GetMethodName(publicMethod)
                : descriptionAttribute.Description;
            
            return true;
        }
        private static List<OperationMetadata> GetNodes(OperationMetadata node, ReplicationDocumentWithClusterInformation replicationDocument)
        {
            var nodes = replicationDocument.Destinations
                .Select(x => ConvertReplicationDestinationToOperationMetadata(x, x.ClusterInformation))
                .Where(x => x != null)
                .ToList();

            nodes.Add(new OperationMetadata(node.Url, node.Credentials, replicationDocument.ClusterInformation));

            return nodes;
        }
Example #26
0
        public void ParamsMatch()
        {
            var method1 = typeof(TestHandler).GetMethod("ParamTest1");
            var method2 = typeof(TestHandler).GetMethod("ParamTest2");

            var metadata = new OperationMetadata(new UriModel {
                Uri = "/some/uri/{myString}"
            }, null);

            Assert.That(_sut.Discover(method1, metadata), Is.True);
            Assert.That(_sut.Discover(method2, metadata), Is.False);
        }
        public void CanFindQueryParamForPrimativeType()
        {
            var methodToDetect = typeof(TestHandler).GetMethod("GetInt");

            var metadata = new OperationMetadata(new UriModel {
                Uri = "/some/uri?s={i}"
            }, null);

            _sut.Discover(methodToDetect, metadata);

            Assert.That(metadata.InputParameters[0].LocationType, Is.EqualTo(InputParameter.LocationTypes.Query));
        }
        public void CanFindPathParam()
        {
            var methodToDetect = typeof(TestHandler).GetMethod("GetString");

            var metadata = new OperationMetadata(new UriModel {
                Uri = "/some/uri/{s}"
            }, null);

            _sut.Discover(methodToDetect, metadata);

            Assert.That(metadata.InputParameters[0].LocationType, Is.EqualTo(InputParameter.LocationTypes.Path));
        }
        public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetdata)
        {
            var possibleResponseCodes = publicMethod.GetCustomAttributes<PossibleResponseCodeAttribute>() ??
                                        new List<PossibleResponseCodeAttribute>();

            foreach (var code in possibleResponseCodes)
            {
                methodMetdata.ResponseCodes.Add(new ResponseCode(code.StatusCode, code.Description));
            }

            return true;
        }
        public void InfersSimpleParamToBeQueryStringWhenNotSpecified()
        {
            var methodToDetect = typeof(TestHandler).GetMethod("GetString");

            var metadata = new OperationMetadata(new UriModel {
                Uri = "/some/uri"
            }, null);

            _sut.Discover(methodToDetect, metadata);

            Assert.That(metadata.InputParameters[0].LocationType, Is.EqualTo(InputParameter.LocationTypes.Query));
        }
        private OperationMetadata GetNodeForReadOperation(OperationMetadata node)
        {
            Debug.Assert(node != null);

            var nodes = NodeUrls;
            var nodeIndex = readStripingBase % nodes.Count;
            var readNode = nodes[nodeIndex];
            if (ShouldExecuteUsing(readNode))
                return readNode;

            return node;
        }
        public void InfersComplexParamToBeBody()
        {
            var methodToDetect = typeof(TestHandler).GetMethod("GetRequest");

            var metadata = new OperationMetadata(new UriModel {
                Uri = "/some/uri"
            }, null);

            _sut.Discover(methodToDetect, metadata);

            Assert.That(metadata.InputParameters[0].LocationType, Is.EqualTo(InputParameter.LocationTypes.Body));
        }
        public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetdata)
        {
            var possibleResponseCodes = publicMethod.GetCustomAttributes <PossibleResponseCodeAttribute>() ??
                                        new List <PossibleResponseCodeAttribute>();

            foreach (var code in possibleResponseCodes)
            {
                methodMetdata.ResponseCodes.Add(new ResponseCode(code.StatusCode, code.Description));
            }

            return(true);
        }
Example #34
0
        public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetdata)
        {
            var exclusions = new List <string> {
                "ToString", "GetType", "GetHashCode", "Equals"
            };
            var allowedVerbs = new List <string> {
                "GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS"
            };

            if (exclusions.Contains(publicMethod.Name))
            {
                return(false);
            }

            var nameUpper = publicMethod.Name.ToUpper();

            var methodAttribute = HttpOperationAttribute.Find(publicMethod);

            if (methodAttribute != null)
            {
                /*
                 * If the name configured in OpenRasta doesn't match
                 * the HttpOperation name, then this is the wrong
                 * method to match
                 */
                var uriName       = methodMetdata.Uri.Name;
                var operationName = methodAttribute.ForUriName;
                if (!string.IsNullOrWhiteSpace(uriName) && !string.IsNullOrWhiteSpace(operationName) &&
                    !uriName.Equals(operationName, StringComparison.OrdinalIgnoreCase))
                {
                    return(false);
                }

                methodMetdata.HttpVerb = methodAttribute.Method;

                return(true);
            }

            if (allowedVerbs.Contains(nameUpper))
            {
                methodMetdata.HttpVerb = nameUpper;
                return(true);
            }

            foreach (var verb in allowedVerbs.Where(nameUpper.StartsWith))
            {
                methodMetdata.HttpVerb = verb;
                return(true);
            }

            return(false);
        }
        public void IfComplexTypeAndSpecifiedInQuery()
        {
            var methodToDetect = typeof(TestHandler).GetMethod("GetRequest");

            var metadata = new OperationMetadata(new UriModel {
                Uri = "/some/uri?req={req}"
            }, null);

            _sut.Discover(methodToDetect, metadata);

            Assert.That(metadata.InputParameters[0].LocationType, Is.EqualTo(InputParameter.LocationTypes.Query));
            Assert.That(metadata.InputParameters[0].Type, Is.EqualTo(typeof(string)));
        }
        /// <summary>
        /// This will change the leader node to the given node and raise the leader changed event if the
        /// new leader was set to a value not equal to null.
        /// </summary>
        /// <param name="newLeader">The new leader to be set.</param>
        /// <param name="isRealLeader">An indication if this is a real leader or just the primary, this will affect if we raise the leader selected event.</param>
        /// <returns>true if the leader node was changed from null to the given value, otherwise returns false</returns>
        private bool SetLeaderNodeIfLeaderIsNull(OperationMetadata newLeader, bool isRealLeader = true)
        {
            var changed = (Interlocked.CompareExchange(ref leaderNode, newLeader, null) == null);

            if (changed && isRealLeader && newLeader != null)
            {
                leaderNodeSelected.Set();
            }
            if (Log.IsDebugEnabled && changed)
            {
                Log.Debug($"Leader node is changing from null to {newLeader}, isRealLeader={isRealLeader}.");
            }
            return(changed);
        }
Example #37
0
        public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetdata)
        {
            var declaringTypeName = "";

            if (publicMethod.DeclaringType != null)
            {
                declaringTypeName = publicMethod.DeclaringType.Name + ".";
            }

            methodMetdata.Summary = "Calls " + declaringTypeName + publicMethod.Name;
            methodMetdata.Name    = publicMethod.Name;

            return(true);
        }
        public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetdata)
        {
            var exclusions = new List<string> {"ToString", "GetType", "GetHashCode", "Equals"};
            var allowedVerbs = new List<string> {"GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS"};

            if (exclusions.Contains(publicMethod.Name))
            {
                return false;
            }

            var nameUpper = publicMethod.Name.ToUpper();

            var methodAttribute = HttpOperationAttribute.Find(publicMethod);
            if (methodAttribute != null)
            {
                /*
                 * If the name configured in OpenRasta doesn't match
                 * the HttpOperation name, then this is the wrong
                 * method to match
                 */
                var uriName = methodMetdata.Uri.Name;
                var operationName = methodAttribute.ForUriName;
                if (!string.IsNullOrWhiteSpace(uriName) && !string.IsNullOrWhiteSpace(operationName) &&
                    !uriName.Equals(operationName, StringComparison.OrdinalIgnoreCase))
                {
                    return false;
                }

                methodMetdata.HttpVerb = methodAttribute.Method;

                return true;
            }

            if (allowedVerbs.Contains(nameUpper))
            {
                methodMetdata.HttpVerb = nameUpper;
                return true;
            }

            foreach (var verb in allowedVerbs.Where(nameUpper.StartsWith))
            {
                methodMetdata.HttpVerb = verb;
                return true;
            }

            return false;
        }
        public bool Discover(MethodInfo publicMethod, OperationMetadata methodMetdata)
        {
            methodMetdata.InputParameters = publicMethod.GetParameters().Select(param => new InputParameter
            {
                Name = param.Name,
                Type = param.ParameterType

            }).ToList();

            foreach (var param in methodMetdata.InputParameters)
            {
                param.LocationType = InputParameter.LocationTypes.Query;

                if (methodMetdata.UriParser.HasParam(param.Name))
                {
                    param.LocationType = methodMetdata.UriParser.HasPathParam(param.Name)
                        ? InputParameter.LocationTypes.Path
                        : InputParameter.LocationTypes.Query;

                    if (!param.Type.IsPrimitive)
                    {
                        param.Type = typeof(string);
                    }
                }

                if (!TypeMapper.IsTypeSwaggerPrimitive(param.Type))
                {
                    param.LocationType =  InputParameter.LocationTypes.Body;
                }
            }

            var requiredHeaders = publicMethod.GetCustomAttributes<RequestHeaderAttribute>();
            foreach (var header in requiredHeaders)
            {
                methodMetdata.InputParameters.Add(new InputParameter
                {
                    Name = header.Name,
                    Type = header.Type,
                    LocationType = InputParameter.LocationTypes.Header,
                    IsRequired = header.IsRequired
                });
            }

            return true;
        }