From 18b67bd725b9fab83f401bc86fb74f731ef1575a Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 11 Dec 2022 18:03:16 +0000 Subject: [PATCH] Elle est pas belle la vie ? --- src/isn.abst/isn.abst.csproj | 3 ++- src/isn/Program.cs | 10 ++++++++++ src/isn/isn.csproj | 1 + src/isnd/Program.cs | 7 ++++--- src/isnd/Startup.cs | 22 ++++++++++++++++++++++ src/isnd/Views/Home/About.cshtml | 1 + src/isnd/isnd.csproj | 1 + 7 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/isn.abst/isn.abst.csproj b/src/isn.abst/isn.abst.csproj index 69192d4..dc4b0d8 100644 --- a/src/isn.abst/isn.abst.csproj +++ b/src/isn.abst/isn.abst.csproj @@ -2,7 +2,7 @@ 1.0.1 1.0.5 - netcoreapp2.1 + net451; net472; net4.8; netcoreapp2.1; net6.0 NETSDK1138 1.0.5.0 1.0.5.0 @@ -10,5 +10,6 @@ + \ No newline at end of file diff --git a/src/isn/Program.cs b/src/isn/Program.cs index 4e3db1a..32004ea 100644 --- a/src/isn/Program.cs +++ b/src/isn/Program.cs @@ -24,6 +24,7 @@ namespace isn { "s|source=", "use source", val => currentSource = currentSource ?? val }, { "h|help", "show this message and exit", h => shouldShowPushHelp = h != null }, }; + private static readonly string _configFileName = Path.Combine( Path.Combine(Environment.GetFolderPath( @@ -34,6 +35,7 @@ namespace isn public const string push = "push"; static readonly OptionSet options = new OptionSet { { "h|help", "show this message and exit", h => shouldShowHelp = h != null }, + { "v|version", "show soft version info and exit", h => shouldShowVersion = h != null } }; static readonly OptionSet pushoptions = new OptionSet { @@ -51,6 +53,7 @@ namespace isn }; private static bool shouldShowHelp; + private static bool shouldShowVersion; private static bool shouldShowSourceHelp; private static bool shouldShowPushHelp; private static string apiKey = null; @@ -150,6 +153,7 @@ namespace isn { Run = sargs => Add(sargs) }; + commandSet.Add(add); var pushCmd = new Command(push) @@ -174,6 +178,7 @@ namespace isn { Run = sargs => StoreApiKey(sargs) }; + commandSet.Add(pushCmd); commandSet.Add(setapikey); commandSet.Add(srcCmd); @@ -202,6 +207,11 @@ namespace isn return 1; } + if (shouldShowVersion) + { + Console.WriteLine("isn version " + GitVersionInformation.AssemblySemFileVer); + } + int runCode = commandSet.Run(args); return (runCode == 0 && pushKO > 0) ? 500 : runCode; diff --git a/src/isn/isn.csproj b/src/isn/isn.csproj index 110a1bc..a32d076 100644 --- a/src/isn/isn.csproj +++ b/src/isn/isn.csproj @@ -20,6 +20,7 @@ + diff --git a/src/isnd/Program.cs b/src/isnd/Program.cs index 9b0ba1d..6147eb8 100644 --- a/src/isnd/Program.cs +++ b/src/isnd/Program.cs @@ -17,9 +17,10 @@ namespace isnd BuildWebHost(args).Run(); } - public static IWebHost BuildWebHost(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseStartup() + public static IWebHost BuildWebHost(string[] args) { + var host = WebHost.CreateDefaultBuilder(args).UseStartup() .Build(); + return host; + } } } diff --git a/src/isnd/Startup.cs b/src/isnd/Startup.cs index 2441cd0..eafa792 100644 --- a/src/isnd/Startup.cs +++ b/src/isnd/Startup.cs @@ -17,6 +17,8 @@ using Unleash; using Microsoft.Extensions.Options; using isnd.Helpers; using Microsoft.IdentityModel.Tokens; +using System; +using Microsoft.OpenApi.Models; namespace isnd { @@ -93,6 +95,24 @@ namespace isnd ValidateAudience = false }; }); + services.AddSwaggerGen(options => + options.SwaggerDoc("v1", new OpenApiInfo + { + Version = "v1", + Title = "ToDo API", + Description = "An ASP.NET Core Web API for managing ToDo items", + TermsOfService = new Uri("https://isn.pschneider.fr/terms"), + Contact = new OpenApiContact + { + Name = "Example Contact", + Url = new Uri("https://isn.pschneider.fr/contact") + }, + License = new OpenApiLicense + { + Name = "Example License", + Url = new Uri("https://isn.pschneider.fr/license") + } + })); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -104,6 +124,8 @@ namespace isnd { app.UseDeveloperExceptionPage(); app.UseMigrationsEndPoint(); + app.UseSwagger(); + app.UseSwaggerUI(); } else { diff --git a/src/isnd/Views/Home/About.cshtml b/src/isnd/Views/Home/About.cshtml index d6c9ce5..c1b5d0e 100644 --- a/src/isnd/Views/Home/About.cshtml +++ b/src/isnd/Views/Home/About.cshtml @@ -5,3 +5,4 @@

@ViewData["Message"]

Use this area to provide additional information.

+ diff --git a/src/isnd/isnd.csproj b/src/isnd/isnd.csproj index 8debd22..2aeb0d3 100644 --- a/src/isnd/isnd.csproj +++ b/src/isnd/isnd.csproj @@ -29,6 +29,7 @@
+