コード例 #1
0
        public static string RefinePropertyName(string s)
        {
            if (String.IsNullOrEmpty(s))
            {
                return(s);
            }

            return(NameFunc.ReplaceDashToTitleCase((NameFunc.ToTitleCase(s.Replace("$", "").Replace(':', '_').Replace('-', '_').Replace('.', '_')
                                                                         .Replace('[', '_').Replace(']', '_').Replace('/', '_').Replace('#', '_').Replace('@', '_')
                                                                         .Replace(' ', '_')))));
        }
コード例 #2
0
        /// <summary>
        /// Container class name for containing client functions, according OpenApiOperation and operation path.
        /// </summary>
        /// <param name="op"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public string GetContainerName(OpenApiOperation op, string path)
        {
            switch (settings.ContainerNameStrategy)
            {
            case ContainerNameStrategy.Path:
                return(NameFunc.ReplaceDashToTitleCase(PathToActionOrContainerName(path) + settings.ContainerNameSuffix));

            case ContainerNameStrategy.Tags:
                if (op.Tags != null && op.Tags.Count > 0)
                {
                    return(NameFunc.ReplaceDashToTitleCase(ToTitleCase(op.Tags[0].Name) + settings.ContainerNameSuffix));                           //todo: concanate multiple ones?
                }
                else
                {
                    return(settings.ContainerClassName);
                }

            default:
                return(settings.ContainerClassName);
            }
        }
コード例 #3
0
        /// <summary>
        /// Generate action name hopefully unique across all paths and operations, under a god container class. Consisting of path, httpMethod and parameters.
        /// </summary>
        /// <param name="op"></param>
        /// <param name="httpMethod"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        string ComposeActionNameWithPath(OpenApiOperation op, string httpMethod, string path)
        {
            string byWhat = String.Join("And", op.Parameters.Where(p => p.In == ParameterLocation.Query).Select(p => NameFunc.ToTitleCase(NameFunc.RefineParameterName(p.Name))));

            return(NameFunc.ReplaceDashToTitleCase(PathToActionOrContainerName(path) + httpMethod + (String.IsNullOrEmpty(byWhat) ? String.Empty : "By" + byWhat)));
        }