public string GetTypeString() { string result = ""; switch (type) { case "object": result = @ref; break; case "array": return(items.GetTypeString() + "[]"); case "string": if (@enum != null && @enum.Count > 0) { return($"({string.Join(" | ", @enum.Select(x => x is string ? "'" + Regex.Escape(x.ToString()) + "'" : x))})"); } return("string"); default: result = type ?? @ref; break; } if (result?.StartsWith("#") ?? false) { return(PreProcessing.FixTypeName(result.Split('/').Last())); } return(result != null?PreProcessing.FixTypeName(result) : null); }
public string GetTypeString() { string result = ""; switch (type) { case "object": result = this is Parameter param ? param.@ref : "object"; break; case "array": return(items.GetTypeString() + "[]"); case "string": if (@enum != null && @enum.Count > 0) { return($"({string.Join(" | ", @enum.Select(x => x is string ? "'" + Regex.Escape(x.ToString()) + "'" : x))})"); } return("string"); default: if (type != null) { result = type; break; } if (this is Parameter param_) { result = param_.@ref; result = result ?? ((param_.@in == "path") ? "string" : param_.schema.GetTypeString()); result = result ?? "object"; } break; } if (result?.StartsWith("#") ?? false) { return(PreProcessing.FixTypeName(result.Split('/').Last())); } return(result != null?PreProcessing.FixTypeName(result) : null); }