diff --git a/parser/Parser/EndpointParser.cs b/parser/Parser/EndpointParser.cs index ee6d032..90efbc4 100644 --- a/parser/Parser/EndpointParser.cs +++ b/parser/Parser/EndpointParser.cs @@ -34,7 +34,7 @@ namespace Parser string basePath = string.Empty; if (openApiDocument.Servers.Any()) { - basePath = new Uri(openApiDocument.Servers.First().Url).AbsolutePath; + basePath = GetUriFromServer(openApiDocument.Servers.First())?.AbsolutePath; } if (basePath == "/") @@ -42,5 +42,17 @@ namespace Parser return basePath; } + + static Uri GetUriFromServer(OpenApiServer server) + { + try + { + return new Uri(server.Url); + } + catch (UriFormatException) + { + return null; + } + } } }