Пример #1
0
 private ApiGuruApi GetApiInfo(string apiKey, string projectFolderPath)
 {
     try
     {
         return(ApiGuruApi.LoadFromDisk(projectFolderPath + @"\" + apiKey + @"\info.json"));
     }
     catch (Exception e)
     {
         Out.PrintLine("Cannot open " + projectFolderPath + @"\" + apiKey + @"\info.json, Exception: " + e.Message, ConsoleColor.Red);
         return(null);
     }
 }
Пример #2
0
        public void StartBulkAnalysis(IList <Alias> apis, bool preferredOnly)
        {
            bool   csvHeaderAdded = false;
            string startDate      = DateTime.Now.ToString(String.Format("yyyy-MM-dd_HH.mm.ss.FFF"));

            Out.PrintHeaderBulkAnalysisStart(startDate);

            foreach (Alias api in apis)
            {
                //load API info
                ApiGuruApi apiInfo = GetApiInfo(api.Key, ProjectFolderPath);
                if (apiInfo == null)
                {
                    continue;
                }

                //load all versions
                IList <Alias> versions = GetVersionAlias(api.Key, ProjectFolderPath);
                if (versions == null)
                {
                    continue;
                }

                foreach (Alias version in versions)
                {
                    if (!preferredOnly || (preferredOnly && apiInfo.Preferred.CompareTo(version.Value) == 0))
                    {
                        //load version Info
                        ApiGuruApiVersion versionInfo = apiInfo.Versions.Versions[version.Value];

                        //determine documentation path
                        string rawContent = LoadOpenApiFile(api.Key, version.Key, ProjectFolderPath);

                        //start analysis
                        AnalysisResult analysisResult = AnalyzeSingleApi(rawContent, api.Key, api.Value, version.Key, version.Value, apiInfo.Added, versionInfo.Added, LinkAnalyzerFactory.Create(IsNameCaseInvariant, AllowExactMatch, AllowPropertyNameContainsParameterName, AllowParameterNameContainsPropertyName));
                        Out.PrintResult(analysisResult);

                        //append results to file
                        string csvContent = "";
                        if (!csvHeaderAdded)
                        {
                            csvContent    += analysisResult.CsvHeader;
                            csvHeaderAdded = true;
                        }
                        csvContent += analysisResult.ToCsv;
                        File.AppendAllText(ProjectFolderPath + @"\" + startDate + ".csv", csvContent);
                    }
                }
            }
            Out.PrintHeaderBulkAnalysisFinish(DateTime.Now.ToString(String.Format("yyyy-MM-dd_HH.mm.ss.FFF")));
        }