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(' ', '_'))))); }
/// <summary> /// Compose action name according to tags, httpMethod and Parameters. /// </summary> /// <param name="op"></param> /// <param name="httpMethod"></param> /// <returns></returns> public static string ComposeActionName(OpenApiOperation op, string httpMethod) { if (op.Tags == null || op.Tags.Count == 0) { throw new ArgumentException("OpenApiOperation does not contain tags for composing action name."); } string byWhat = String.Join("And", op.Parameters.Where(p => p.In == ParameterLocation.Path || p.In == ParameterLocation.Query).Select(p => NameFunc.ToTitleCase(NameFunc.RefineParameterName(p.Name)))); return(ToTitleCase(op.Tags[0].Name) + httpMethod + (String.IsNullOrEmpty(byWhat) ? String.Empty : "By" + byWhat)); }
/// <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(PathToActionOrContainerName(path) + httpMethod + (String.IsNullOrEmpty(byWhat) ? String.Empty : "By" + byWhat)); }