示例#1
0
        public string GetUniqueOperationId(ApiDescription apiDesc, HashSet <string> operationNames)
        {
            string operationId;

            if (_options.OperationIdResolver != null)
            {
                operationId = _options.OperationIdResolver(apiDesc);
            }
            else
            {
                // default behaviour
                operationId = apiDesc.FriendlyId();
                if (operationNames.Contains(operationId))
                {
                    operationId = apiDesc.FriendlyId2();
                }

                var nextFriendlyIdPostfix = 1;
                while (operationNames.Contains(operationId))
                {
                    operationId = $"{apiDesc.FriendlyId2()}_{nextFriendlyIdPostfix}";
                    nextFriendlyIdPostfix++;
                }
            }

            operationNames.Add(operationId);
            return(operationId);
        }
示例#2
0
        public string GetUniqueFriendlyId(ApiDescription apiDesc, HashSet <string> operationNames)
        {
            string friendlyId = apiDesc.FriendlyId();

            if (operationNames.Contains(friendlyId))
            {
                friendlyId = apiDesc.FriendlyId2();
            }

            int nextFriendlyIdPostfix = 1;

            while (operationNames.Contains(friendlyId))
            {
                friendlyId = string.Format("{0}_{1}", apiDesc.FriendlyId2(), nextFriendlyIdPostfix);
                nextFriendlyIdPostfix++;
            }
            operationNames.Add(friendlyId);
            return(friendlyId);
        }