diff --git a/src/Criteo.OpenApi.Comparator.Cli/Criteo.OpenApi.Comparator.Cli.csproj b/src/Criteo.OpenApi.Comparator.Cli/Criteo.OpenApi.Comparator.Cli.csproj index 452fd7e..535f87e 100644 --- a/src/Criteo.OpenApi.Comparator.Cli/Criteo.OpenApi.Comparator.Cli.csproj +++ b/src/Criteo.OpenApi.Comparator.Cli/Criteo.OpenApi.Comparator.Cli.csproj @@ -15,7 +15,7 @@ Criteo Criteo Copyright (c) Criteo Technology. All rights reserved. - 0.7.3 + 1.0.0 https://github.com/criteo/openapi-comparator https://github.com/criteo/openapi-comparator Criteo, OpenApi, OpenApi-Comparator, OpenApi-Diff, Swagger @@ -23,6 +23,7 @@ true true openapi-compare + ./nupkg Readme.md diff --git a/src/Criteo.OpenApi.Comparator.Cli/Program.cs b/src/Criteo.OpenApi.Comparator.Cli/Program.cs index 4eb408c..7973a43 100644 --- a/src/Criteo.OpenApi.Comparator.Cli/Program.cs +++ b/src/Criteo.OpenApi.Comparator.Cli/Program.cs @@ -5,6 +5,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Net; +using System.Net.Http; using System.Text.Json; namespace Criteo.OpenApi.Comparator.Cli @@ -45,15 +47,41 @@ public static int Main(string[] args) } private static bool TryReadFile(string path, out string fileContent) + { + bool readOk = TryReadDistantFile(path, out fileContent); + if (!readOk) + { + TryReadLocalFile(path, out fileContent); + } + return readOk; + } + + private static bool TryReadDistantFile(string url, out string fileContent) + { + try + { + using HttpClient wc = new HttpClient(); + fileContent = wc.GetStringAsync(url).Result; + return true; + } + catch (Exception e) + { + Console.WriteLine($"File not found for: {url} with the message {e.Message}"); + fileContent = null; + return false; + } + } + + private static bool TryReadLocalFile(string path, out string fileContent) { try { fileContent = File.ReadAllText(path); return true; } - catch (FileNotFoundException) + catch (FileNotFoundException f) { - Console.WriteLine($"File not found for: {path}."); + Console.WriteLine($"File not found for: {path} with the message {f.Message}"); fileContent = null; return false; }