public AnalysisResult AnalyzeSingleApi(string rawContent, string apiKey, string apiName, string versionKey, string versionName, string apiAdded, string versionAdded, ILinkAnalyzer linkAnalyzer) { OpenApiDiagnostic openApiDiagnostic = new OpenApiDiagnostic(); OpenApiDocument openApiDocument = null; try { //step 1: convert OpenAPI documentation into object model openApiDocument = new OpenApiStringReader().Read(rawContent, out openApiDiagnostic); } catch (Exception e) { // possibly IO Exception or Exception due to mal-formed OpenAPI documentation return(AnalysisResult.Create(apiKey, apiName, versionKey, versionName, apiAdded, versionAdded, null, 0, 0, false, e)); } //step 2: write diagnostic to log int openApiReaderErrors = 0; foreach (OpenApiError openApiError in openApiDiagnostic.Errors) { openApiReaderErrors++; //TODO: write to log } //step 3: create URI Model UriModel uriModel = null; try { uriModel = CustomizedUriModelFactory.Instance.Create(openApiDocument); } catch (Exception e) { return(AnalysisResult.Create(apiKey, apiName, versionKey, versionName, apiAdded, versionAdded, null, openApiReaderErrors, 0, false, e)); } //step 4: check whether URI Model contains variable path segments that have more than one path parameter bool hasUriModelVariablePathSegmentsWithMoreThanOnePathParameter = HasUriModelVariablePathSegmentsWithMoreThanOnePathParameter(uriModel); if (hasUriModelVariablePathSegmentsWithMoreThanOnePathParameter) { return(AnalysisResult.Create(apiKey, apiName, versionKey, versionName, apiAdded, versionAdded, uriModel, openApiReaderErrors, 0, true, null)); } //step 5: identify reachability paths int missingMediaCounter = 0; try { IList <PathSegment> pathSegmentsRepresentingResources = uriModel.Root.QuerySubTree.HasOperations().Results; for (int i = 0; i < pathSegmentsRepresentingResources.Count; i++) { ((CustomizedPathSegment)pathSegmentsRepresentingResources[i]).IdentifyReachabilityPaths(linkAnalyzer); Out.UpdateStatusBar(((double)i / (double)pathSegmentsRepresentingResources.Count) * 100); } missingMediaCounter = linkAnalyzer.MissingMediaCounter; } catch (Exception e) { //possibly Exception due to mal-formed OpenAPI documentation return(AnalysisResult.Create(apiKey, apiName, versionKey, versionName, apiAdded, versionAdded, uriModel, openApiReaderErrors, 0, hasUriModelVariablePathSegmentsWithMoreThanOnePathParameter, e)); } return(AnalysisResult.Create(apiKey, apiName, versionKey, versionName, apiAdded, versionAdded, uriModel, openApiReaderErrors, missingMediaCounter, hasUriModelVariablePathSegmentsWithMoreThanOnePathParameter, null)); }