From ad455d858cdec09ca96fa6b1b382731dec2cc5f2 Mon Sep 17 00:00:00 2001 From: Jason Taylor Date: Tue, 25 Oct 2022 21:33:35 +1000 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20Switch=20to=20Minimal=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CleanArchitecture.sln | 21 +- .../app/fetch-data/fetch-data.component.ts | 12 +- .../src/app/nav-menu/nav-menu.component.html | 16 +- .../ClientApp/src/app/todo/todo.component.ts | 15 +- src/WebUI/ClientApp/src/app/web-api-client.ts | 776 ++++++------------ src/WebUI/ConfigureServices.cs | 6 +- src/WebUI/Controllers/ApiControllerBase.cs | 17 - src/WebUI/Controllers/TodoItemsController.cs | 66 -- src/WebUI/Controllers/TodoListsController.cs | 57 -- .../Controllers/WeatherForecastController.cs | 13 - .../Filters/ApiExceptionFilterAttribute.cs | 122 --- src/WebUI/GlobalUsings.cs | 2 + src/WebUI/Infrastructure/AbstractEndpoint.cs | 60 ++ .../Infrastructure/ApiExceptionFilter.cs | 106 +++ src/WebUI/Infrastructure/IEndpoint.cs | 6 + .../RouteHandlerBuilderExtensions.cs | 17 + .../WebApplicationExtensions.cs | 27 + .../OidcConfiguration/OidcConfiguration.cs | 16 + src/WebUI/Program.cs | 12 +- src/WebUI/Services/CurrentUser.cs | 2 +- src/WebUI/TodoItems/CreateTodoItem.cs | 12 + src/WebUI/TodoItems/DeleteTodoItem.cs | 16 + src/WebUI/TodoItems/UpdateTodoItem.cs | 19 + src/WebUI/TodoItems/UpdateTodoItemDetail.cs | 19 + src/WebUI/TodoLists/CreateTodoList.cs | 12 + src/WebUI/TodoLists/DeleteTodoList.cs | 16 + src/WebUI/TodoLists/ExportTodos.cs | 16 + src/WebUI/TodoLists/GetTodoLists.cs | 12 + src/WebUI/TodoLists/UpdateTodoList.cs | 19 + .../WeatherForecasts/GetWeatherForecasts.cs | 12 + src/WebUI/WebUI.csproj | 2 + src/WebUI/wwwroot/api/specification.json | 574 +++++-------- 32 files changed, 913 insertions(+), 1185 deletions(-) delete mode 100644 src/WebUI/Controllers/ApiControllerBase.cs delete mode 100644 src/WebUI/Controllers/TodoItemsController.cs delete mode 100644 src/WebUI/Controllers/TodoListsController.cs delete mode 100644 src/WebUI/Controllers/WeatherForecastController.cs delete mode 100644 src/WebUI/Filters/ApiExceptionFilterAttribute.cs create mode 100644 src/WebUI/GlobalUsings.cs create mode 100644 src/WebUI/Infrastructure/AbstractEndpoint.cs create mode 100644 src/WebUI/Infrastructure/ApiExceptionFilter.cs create mode 100644 src/WebUI/Infrastructure/IEndpoint.cs create mode 100644 src/WebUI/Infrastructure/RouteHandlerBuilderExtensions.cs create mode 100644 src/WebUI/Infrastructure/WebApplicationExtensions.cs create mode 100644 src/WebUI/OidcConfiguration/OidcConfiguration.cs create mode 100644 src/WebUI/TodoItems/CreateTodoItem.cs create mode 100644 src/WebUI/TodoItems/DeleteTodoItem.cs create mode 100644 src/WebUI/TodoItems/UpdateTodoItem.cs create mode 100644 src/WebUI/TodoItems/UpdateTodoItemDetail.cs create mode 100644 src/WebUI/TodoLists/CreateTodoList.cs create mode 100644 src/WebUI/TodoLists/DeleteTodoList.cs create mode 100644 src/WebUI/TodoLists/ExportTodos.cs create mode 100644 src/WebUI/TodoLists/GetTodoLists.cs create mode 100644 src/WebUI/TodoLists/UpdateTodoList.cs create mode 100644 src/WebUI/WeatherForecasts/GetWeatherForecasts.cs diff --git a/CleanArchitecture.sln b/CleanArchitecture.sln index 00afa1572..34fefbe66 100644 --- a/CleanArchitecture.sln +++ b/CleanArchitecture.sln @@ -19,8 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Domain.UnitTests", "tests\D EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Application.IntegrationTests", "tests\Application.IntegrationTests\Application.IntegrationTests.csproj", "{277029AF-D9E1-4B75-9F11-48FEA7345AD7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebUI", "src\WebUI\WebUI.csproj", "{22454EE9-16B3-4B7A-8352-37E59B858155}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E2DA20AA-28D1-455C-BF50-C49A8F831633}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig @@ -28,6 +26,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution global.json = global.json EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebUI", "src\WebUI\WebUI.csproj", "{D62B82F7-3317-4BB4-85B2-3116C50C7585}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebUI.AcceptanceTests", "tests\WebUI.AcceptanceTests\WebUI.AcceptanceTests.csproj", "{006B607C-D181-47EC-82D7-06582A0F31DE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -58,10 +60,14 @@ Global {277029AF-D9E1-4B75-9F11-48FEA7345AD7}.Debug|Any CPU.Build.0 = Debug|Any CPU {277029AF-D9E1-4B75-9F11-48FEA7345AD7}.Release|Any CPU.ActiveCfg = Release|Any CPU {277029AF-D9E1-4B75-9F11-48FEA7345AD7}.Release|Any CPU.Build.0 = Release|Any CPU - {22454EE9-16B3-4B7A-8352-37E59B858155}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {22454EE9-16B3-4B7A-8352-37E59B858155}.Debug|Any CPU.Build.0 = Debug|Any CPU - {22454EE9-16B3-4B7A-8352-37E59B858155}.Release|Any CPU.ActiveCfg = Release|Any CPU - {22454EE9-16B3-4B7A-8352-37E59B858155}.Release|Any CPU.Build.0 = Release|Any CPU + {D62B82F7-3317-4BB4-85B2-3116C50C7585}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D62B82F7-3317-4BB4-85B2-3116C50C7585}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D62B82F7-3317-4BB4-85B2-3116C50C7585}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D62B82F7-3317-4BB4-85B2-3116C50C7585}.Release|Any CPU.Build.0 = Release|Any CPU + {006B607C-D181-47EC-82D7-06582A0F31DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {006B607C-D181-47EC-82D7-06582A0F31DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {006B607C-D181-47EC-82D7-06582A0F31DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {006B607C-D181-47EC-82D7-06582A0F31DE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -73,7 +79,8 @@ Global {DEFF4009-1FAB-4392-80B6-707E2DC5C00B} = {664D406C-2F83-48F0-BFC3-408D5CB53C65} {DC37FD87-552C-4613-9F16-1537CA522898} = {664D406C-2F83-48F0-BFC3-408D5CB53C65} {277029AF-D9E1-4B75-9F11-48FEA7345AD7} = {664D406C-2F83-48F0-BFC3-408D5CB53C65} - {22454EE9-16B3-4B7A-8352-37E59B858155} = {6ED356A7-8B47-4613-AD01-C85CF28491BD} + {D62B82F7-3317-4BB4-85B2-3116C50C7585} = {6ED356A7-8B47-4613-AD01-C85CF28491BD} + {006B607C-D181-47EC-82D7-06582A0F31DE} = {664D406C-2F83-48F0-BFC3-408D5CB53C65} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3CB609D9-5D54-4C11-A371-DAAC8B74E430} diff --git a/src/WebUI/ClientApp/src/app/fetch-data/fetch-data.component.ts b/src/WebUI/ClientApp/src/app/fetch-data/fetch-data.component.ts index 066f406a8..a52d02fb2 100644 --- a/src/WebUI/ClientApp/src/app/fetch-data/fetch-data.component.ts +++ b/src/WebUI/ClientApp/src/app/fetch-data/fetch-data.component.ts @@ -1,5 +1,5 @@ import { Component } from '@angular/core'; -import { WeatherForecastClient, WeatherForecast } from '../web-api-client'; +import { WeatherForecastsClient, WeatherForecast } from '../web-api-client'; @Component({ selector: 'app-fetch-data', @@ -8,10 +8,10 @@ import { WeatherForecastClient, WeatherForecast } from '../web-api-client'; export class FetchDataComponent { public forecasts: WeatherForecast[] = []; - constructor(private client: WeatherForecastClient) { - client.get().subscribe({ - next: result => this.forecasts = result, - error: error => console.error(error) - }); + constructor(private client: WeatherForecastsClient) { + client.getWeatherForecasts().subscribe({ + next: result => this.forecasts = result, + error: error => console.error(error) + }); } } diff --git a/src/WebUI/ClientApp/src/app/nav-menu/nav-menu.component.html b/src/WebUI/ClientApp/src/app/nav-menu/nav-menu.component.html index 157418080..351e71e19 100644 --- a/src/WebUI/ClientApp/src/app/nav-menu/nav-menu.component.html +++ b/src/WebUI/ClientApp/src/app/nav-menu/nav-menu.component.html @@ -1,7 +1,5 @@
-