From d34c2bb32c577bab63ec0e27b8988ea458e8e972 Mon Sep 17 00:00:00 2001 From: Millicent Achieng Date: Fri, 2 Feb 2024 02:21:44 +0300 Subject: [PATCH] Report error if base URL in example request is not in config --- ApiDoctor.Console/Program.cs | 2 +- ApiDoctor.Publishing/CSDL/csdlextensionmethods.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ApiDoctor.Console/Program.cs b/ApiDoctor.Console/Program.cs index 3288d7ad..e4d823aa 100644 --- a/ApiDoctor.Console/Program.cs +++ b/ApiDoctor.Console/Program.cs @@ -2570,7 +2570,7 @@ private static HttpRequest PreProcessUrlForSnippetGeneration(HttpRequest request if (!(request.Url.Substring(0, 6).Equals("/beta/") || request.Url.Substring(0, 6).Equals("/v1.0/"))) { //Log the error for the documentation to be fixed. - issues.Warning(ValidationErrorCode.InvalidUrlString, $"The url: {request.Url} does not start a supported api version( /v1.0/ or /beta/ ). File: {method.SourceFile}"); + issues.Warning(ValidationErrorCode.InvalidUrlString, $"The url: {request.Url} does not start with a supported api version( /v1.0/ or /beta/ ). File: {method.SourceFile}"); if (method.SourceFile.DisplayName.Contains("beta")) { diff --git a/ApiDoctor.Publishing/CSDL/csdlextensionmethods.cs b/ApiDoctor.Publishing/CSDL/csdlextensionmethods.cs index 8cbc66d0..2b9242a3 100644 --- a/ApiDoctor.Publishing/CSDL/csdlextensionmethods.cs +++ b/ApiDoctor.Publishing/CSDL/csdlextensionmethods.cs @@ -65,6 +65,7 @@ public static string RequestUriPathOnly(this MethodDefinition method, IssueLogge { if (path.StartsWith(scheme, StringComparison.OrdinalIgnoreCase)) { + issues.For(method.Identifier).Error(ValidationErrorCode.InvalidUrlString, $"Unexpected base URL found in '{method.Request.FirstLineOnly()}'"); int pathStartIndex = path.IndexOf('/', scheme.Length); if (pathStartIndex != -1) {