Elle est pas belle la vie ?

This commit is contained in:
Paul Schneider 2022-12-11 18:03:16 +00:00
commit 18b67bd725
7 changed files with 41 additions and 4 deletions

View file

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<PackageVersion>1.0.1</PackageVersion> <PackageVersion>1.0.1</PackageVersion>
<Version>1.0.5</Version> <Version>1.0.5</Version>
<TargetFrameworks>netcoreapp2.1</TargetFrameworks> <TargetFrameworks>net451; net472; net4.8; netcoreapp2.1; net6.0</TargetFrameworks>
<NoWarn>NETSDK1138</NoWarn> <NoWarn>NETSDK1138</NoWarn>
<AssemblyVersion>1.0.5.0</AssemblyVersion> <AssemblyVersion>1.0.5.0</AssemblyVersion>
<FileVersion>1.0.5.0</FileVersion> <FileVersion>1.0.5.0</FileVersion>
@ -10,5 +10,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="11.0.1" />
<Reference Include="System.ComponentModel.DataAnnotations" Version="4.0.0.0"/>
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -24,6 +24,7 @@ namespace isn
{ "s|source=", "use source", val => currentSource = currentSource ?? val }, { "s|source=", "use source", val => currentSource = currentSource ?? val },
{ "h|help", "show this message and exit", h => shouldShowPushHelp = h != null }, { "h|help", "show this message and exit", h => shouldShowPushHelp = h != null },
}; };
private static readonly string _configFileName = private static readonly string _configFileName =
Path.Combine( Path.Combine(
Path.Combine(Environment.GetFolderPath( Path.Combine(Environment.GetFolderPath(
@ -34,6 +35,7 @@ namespace isn
public const string push = "push"; public const string push = "push";
static readonly OptionSet options = new OptionSet { static readonly OptionSet options = new OptionSet {
{ "h|help", "show this message and exit", h => shouldShowHelp = h != null }, { "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 { static readonly OptionSet pushoptions = new OptionSet {
@ -51,6 +53,7 @@ namespace isn
}; };
private static bool shouldShowHelp; private static bool shouldShowHelp;
private static bool shouldShowVersion;
private static bool shouldShowSourceHelp; private static bool shouldShowSourceHelp;
private static bool shouldShowPushHelp; private static bool shouldShowPushHelp;
private static string apiKey = null; private static string apiKey = null;
@ -150,6 +153,7 @@ namespace isn
{ {
Run = sargs => Add(sargs) Run = sargs => Add(sargs)
}; };
commandSet.Add(add); commandSet.Add(add);
var pushCmd = new Command(push) var pushCmd = new Command(push)
@ -174,6 +178,7 @@ namespace isn
{ {
Run = sargs => StoreApiKey(sargs) Run = sargs => StoreApiKey(sargs)
}; };
commandSet.Add(pushCmd); commandSet.Add(pushCmd);
commandSet.Add(setapikey); commandSet.Add(setapikey);
commandSet.Add(srcCmd); commandSet.Add(srcCmd);
@ -202,6 +207,11 @@ namespace isn
return 1; return 1;
} }
if (shouldShowVersion)
{
Console.WriteLine("isn version " + GitVersionInformation.AssemblySemFileVer);
}
int runCode = commandSet.Run(args); int runCode = commandSet.Run(args);
return (runCode == 0 && pushKO > 0) ? 500 : runCode; return (runCode == 0 && pushKO > 0) ? 500 : runCode;

View file

@ -20,6 +20,7 @@
<PackageReference Include="unleash.client" Version="1.6.1" /> <PackageReference Include="unleash.client" Version="1.6.1" />
<Reference Include="System.Net.Http" Version="4.0.0" /> <Reference Include="System.Net.Http" Version="4.0.0" />
<PackageReference Include="Microsoft.AspNetCore.App" /> <PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="GitVersion.MsBuild" Version="5.6.10*" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="../isn.abst/isn.abst.csproj" /> <ProjectReference Include="../isn.abst/isn.abst.csproj" />

View file

@ -17,9 +17,10 @@ namespace isnd
BuildWebHost(args).Run(); BuildWebHost(args).Run();
} }
public static IWebHost BuildWebHost(string[] args) => public static IWebHost BuildWebHost(string[] args) {
WebHost.CreateDefaultBuilder(args) var host = WebHost.CreateDefaultBuilder(args).UseStartup<Startup>()
.UseStartup<Startup>()
.Build(); .Build();
return host;
}
} }
} }

View file

@ -17,6 +17,8 @@ using Unleash;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using isnd.Helpers; using isnd.Helpers;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
using System;
using Microsoft.OpenApi.Models;
namespace isnd namespace isnd
{ {
@ -93,6 +95,24 @@ namespace isnd
ValidateAudience = false 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. // 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.UseDeveloperExceptionPage();
app.UseMigrationsEndPoint(); app.UseMigrationsEndPoint();
app.UseSwagger();
app.UseSwaggerUI();
} }
else else
{ {

View file

@ -5,3 +5,4 @@
<h3>@ViewData["Message"]</h3> <h3>@ViewData["Message"]</h3>
<p>Use this area to provide additional information.</p> <p>Use this area to provide additional information.</p>

View file

@ -29,6 +29,7 @@
</PackageReference> </PackageReference>
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="4.6.0" /> <PackageReference Include="System.Security.Cryptography.Pkcs" Version="4.6.0" />
<PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="2.1.1" /> <PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="2.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="../isn.abst/isn.abst.csproj" /> <ProjectReference Include="../isn.abst/isn.abst.csproj" />