From 6217054aa5d6a2c2f048a81329e2c6a37dc37bcb Mon Sep 17 00:00:00 2001 From: "c.girardi" Date: Mon, 11 Mar 2024 15:48:34 +0100 Subject: [PATCH] first commit --- .gitignore | 21 ++++++++++++ ApiTest.sln | 16 ++++++++++ ApiTest/ApiTest.csproj | 14 ++++++++ ApiTest/ApiTest.http | 6 ++++ ApiTest/Program.cs | 44 ++++++++++++++++++++++++++ ApiTest/Properties/launchSettings.json | 41 ++++++++++++++++++++++++ ApiTest/appsettings.Development.json | 8 +++++ ApiTest/appsettings.json | 9 ++++++ 8 files changed, 159 insertions(+) create mode 100644 .gitignore create mode 100644 ApiTest.sln create mode 100644 ApiTest/ApiTest.csproj create mode 100644 ApiTest/ApiTest.http create mode 100644 ApiTest/Program.cs create mode 100644 ApiTest/Properties/launchSettings.json create mode 100644 ApiTest/appsettings.Development.json create mode 100644 ApiTest/appsettings.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3e86892 --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +/ApiTest*/[Bb]in/* +/ApiTest*/[Oo]bj/* +/packages/ +/Resources +riderModule.iml +/_ReSharper.Caches/ +/.idea + + +internal.log + +ApiTest.sln.DotSettings.user + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt diff --git a/ApiTest.sln b/ApiTest.sln new file mode 100644 index 0000000..23b7fb9 --- /dev/null +++ b/ApiTest.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiTest", "ApiTest\ApiTest.csproj", "{573A3D1F-F8BE-46D8-B47C-CA852371DC9D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {573A3D1F-F8BE-46D8-B47C-CA852371DC9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {573A3D1F-F8BE-46D8-B47C-CA852371DC9D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {573A3D1F-F8BE-46D8-B47C-CA852371DC9D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {573A3D1F-F8BE-46D8-B47C-CA852371DC9D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/ApiTest/ApiTest.csproj b/ApiTest/ApiTest.csproj new file mode 100644 index 0000000..1060e38 --- /dev/null +++ b/ApiTest/ApiTest.csproj @@ -0,0 +1,14 @@ + + + + net8.0 + enable + enable + + + + + + + + diff --git a/ApiTest/ApiTest.http b/ApiTest/ApiTest.http new file mode 100644 index 0000000..ce879a6 --- /dev/null +++ b/ApiTest/ApiTest.http @@ -0,0 +1,6 @@ +@ApiTest_HostAddress = http://localhost:5284 + +GET {{ApiTest_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/ApiTest/Program.cs b/ApiTest/Program.cs new file mode 100644 index 0000000..161f695 --- /dev/null +++ b/ApiTest/Program.cs @@ -0,0 +1,44 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +var summaries = new[] +{ + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" +}; + +app.MapGet("/weatherforecast", () => + { + var forecast = Enumerable.Range(1, 5).Select(index => + new WeatherForecast + ( + DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + Random.Shared.Next(-20, 55), + summaries[Random.Shared.Next(summaries.Length)] + )) + .ToArray(); + return forecast; + }) + .WithName("GetWeatherForecast") + .WithOpenApi(); + +app.Run(); + +record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) +{ + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); +} \ No newline at end of file diff --git a/ApiTest/Properties/launchSettings.json b/ApiTest/Properties/launchSettings.json new file mode 100644 index 0000000..cca72a0 --- /dev/null +++ b/ApiTest/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:53539", + "sslPort": 44373 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5284", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7143;http://localhost:5284", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/ApiTest/appsettings.Development.json b/ApiTest/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/ApiTest/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/ApiTest/appsettings.json b/ApiTest/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/ApiTest/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}