diff --git a/Api/.idea/.idea.Api.dir/.idea/encodings.xml b/Api/.idea/.idea.Api.dir/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/Api/.idea/.idea.Api.dir/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Api/.idea/.idea.Api.dir/.idea/git_toolbox_blame.xml b/Api/.idea/.idea.Api.dir/.idea/git_toolbox_blame.xml new file mode 100644 index 0000000..7dc1249 --- /dev/null +++ b/Api/.idea/.idea.Api.dir/.idea/git_toolbox_blame.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/Api/.idea/.idea.Api.dir/.idea/indexLayout.xml b/Api/.idea/.idea.Api.dir/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/Api/.idea/.idea.Api.dir/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Api/.idea/.idea.Api.dir/.idea/vcs.xml b/Api/.idea/.idea.Api.dir/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Api/.idea/.idea.Api.dir/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Api/Api.csproj b/Api/Api.csproj new file mode 100644 index 0000000..e06d179 --- /dev/null +++ b/Api/Api.csproj @@ -0,0 +1,14 @@ + + + + net9.0 + enable + enable + + + + + + + + diff --git a/Api/Api.http b/Api/Api.http new file mode 100644 index 0000000..8b62679 --- /dev/null +++ b/Api/Api.http @@ -0,0 +1,6 @@ +@Api_HostAddress = http://localhost:5175 + +GET {{Api_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/Api/Program.cs b/Api/Program.cs new file mode 100644 index 0000000..439056c --- /dev/null +++ b/Api/Program.cs @@ -0,0 +1,48 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddOpenApi(); +builder.Services.AddOpenApiDocument(config => +{ + config.Title = "NSwag Demo API"; +}); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); + app.UseOpenApi(); + 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"); + +app.Run(); + +record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) +{ + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); +} diff --git a/Api/Properties/launchSettings.json b/Api/Properties/launchSettings.json new file mode 100644 index 0000000..7d0e605 --- /dev/null +++ b/Api/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5175", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7081;http://localhost:5175", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Api/appsettings.Development.json b/Api/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Api/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Api/appsettings.json b/Api/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Api/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Api/nswag.json b/Api/nswag.json new file mode 100644 index 0000000..472e100 --- /dev/null +++ b/Api/nswag.json @@ -0,0 +1,73 @@ +{ + "runtime": "Net90", + "defaultVariables": null, + "documentGenerator": { + "fromDocument": { + "url": "http://localhost:5175/swagger/v1/swagger.json", + "output": null, + "newLineBehavior": "Auto" + } + }, + "codeGenerators": { + "openApiToTypeScriptClient": { + "className": "{controller}Client", + "moduleName": "", + "namespace": "", + "typeScriptVersion": 4.0, + "template": "Fetch", + "promiseType": "Promise", + "httpClass": "HttpClient", + "withCredentials": false, + "useSingletonProvider": false, + "injectionTokenType": "OpaqueToken", + "rxJsVersion": 6.0, + "dateTimeType": "Date", + "nullValue": "Undefined", + "generateClientClasses": true, + "generateClientInterfaces": false, + "generateOptionalParameters": true, + "exportTypes": true, + "wrapDtoExceptions": false, + "exceptionClass": "SwaggerException", + "clientBaseClass": null, + "wrapResponses": false, + "wrapResponseMethods": [], + "generateResponseClasses": true, + "responseClass": "SwaggerResponse", + "protectedMethods": [], + "configurationClass": null, + "useTransformOptionsMethod": false, + "useTransformResultMethod": false, + "generateDtoTypes": true, + "operationGenerationMode": "MultipleClientsFromOperationId", + "markOptionalProperties": true, + "generateCloneMethod": false, + "typeStyle": "Class", + "enumStyle": "Enum", + "useLeafType": false, + "classTypes": [], + "extendedClasses": [], + "extensionCode": null, + "generateDefaultValues": true, + "excludedTypeNames": [], + "excludedParameterNames": [], + "handleReferences": false, + "generateTypeCheckFunctions": false, + "generateConstructorInterface": true, + "convertConstructorInterfaceData": false, + "importRequiredTypes": true, + "useGetBaseUrlMethod": false, + "baseUrlTokenName": "API_BASE_URL", + "queryNullValue": "", + "useAbortSignal": false, + "inlineNamedDictionaries": false, + "inlineNamedAny": false, + "includeHttpContext": false, + "templateDirectory": null, + "serviceHost": null, + "serviceSchemes": null, + "output": "ClientApi.ts", + "newLineBehavior": "Auto" + } + } +} \ No newline at end of file