From eab4ce12686194af54723526650b2b017784b332 Mon Sep 17 00:00:00 2001 From: Jason Taylor Date: Tue, 27 Jun 2023 19:11:36 +1000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Fixing=20merge=20issues=20and=20imp?= =?UTF-8?q?roving=20approach.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WebUI/ClientApp/src/app/web-api-client.ts | 2 +- src/WebUI/ConfigureServices.cs | 4 +- src/WebUI/Infrastructure/AbstractEndpoint.cs | 60 ------------------- .../OidcConfiguration/OidcConfiguration.cs | 16 ----- src/WebUI/Program.cs | 7 --- src/WebUI/wwwroot/api/specification.json | 31 +++------- 6 files changed, 10 insertions(+), 110 deletions(-) delete mode 100644 src/WebUI/Infrastructure/AbstractEndpoint.cs delete mode 100644 src/WebUI/OidcConfiguration/OidcConfiguration.cs diff --git a/src/WebUI/ClientApp/src/app/web-api-client.ts b/src/WebUI/ClientApp/src/app/web-api-client.ts index 56cf4e135..b9b5108f3 100644 --- a/src/WebUI/ClientApp/src/app/web-api-client.ts +++ b/src/WebUI/ClientApp/src/app/web-api-client.ts @@ -1,6 +1,6 @@ //---------------------- // -// Generated using the NSwag toolchain v13.17.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v13.19.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org) // //---------------------- diff --git a/src/WebUI/ConfigureServices.cs b/src/WebUI/ConfigureServices.cs index b63c445a3..bd873df03 100644 --- a/src/WebUI/ConfigureServices.cs +++ b/src/WebUI/ConfigureServices.cs @@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Mvc; using ZymLabs.NSwag.FluentValidation; -namespace CleanArchitecture.WebUI; +namespace Microsoft.Extensions.DependencyInjection; public static class ConfigureServices { @@ -29,8 +29,6 @@ public static IServiceCollection AddWebUIServices(this IServiceCollection servic return new FluentValidationSchemaProcessor(provider, validationRules, loggerFactory); }); - services.AddEndpointsApiExplorer(); - // Customise default API behaviour services.Configure(options => options.SuppressModelStateInvalidFilter = true); diff --git a/src/WebUI/Infrastructure/AbstractEndpoint.cs b/src/WebUI/Infrastructure/AbstractEndpoint.cs deleted file mode 100644 index 7f818d7f7..000000000 --- a/src/WebUI/Infrastructure/AbstractEndpoint.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace CleanArchitecture.WebUI.Infrastructure; - -public abstract class AbstractEndpoint : IEndpoint -{ - public abstract void Map(WebApplication app); - - public string Name => GetType().Name; - - public string Group => GetType().Namespace!.Split(".")[^1]; - - public string BaseRoute => $"/api/{Group}/"; - - public RouteHandlerBuilder MapGet(WebApplication app, Delegate handler) => MapGet(app, "", handler); - - public RouteHandlerBuilder MapGet(WebApplication app, string pattern, Delegate handler, bool withDefaults = true) - { - var builder = app.MapGet(BuildRoutePattern(pattern), handler); - - if (withDefaults) - { - builder.WithDefaults(this); - } - - return builder; - } - - public RouteHandlerBuilder MapPost(WebApplication app, Delegate handler) => MapPost(app, "", handler); - - public RouteHandlerBuilder MapPost(WebApplication app, string pattern, Delegate handler) - { - return app.MapPost(BuildRoutePattern(pattern), handler) - .WithDefaults(this); - } - - public RouteHandlerBuilder MapPut(WebApplication app, Delegate handler) => MapPut(app, "", handler); - - public RouteHandlerBuilder MapPut(WebApplication app, string pattern, Delegate handler) - { - return app.MapPut(BuildRoutePattern(pattern), handler) - .WithDefaults(this); - } - - public RouteHandlerBuilder MapDelete(WebApplication app, Delegate handler) => MapDelete(app, "", handler); - - public RouteHandlerBuilder MapDelete(WebApplication app, string pattern, Delegate handler) - { - return app.MapDelete(BuildRoutePattern(pattern), handler) - .WithDefaults(this); - } - - private string BuildRoutePattern(string pattern) - { - if (!pattern.StartsWith("/")) - { - pattern = $"{BaseRoute}{pattern}"; - } - - return pattern; - } -} diff --git a/src/WebUI/OidcConfiguration/OidcConfiguration.cs b/src/WebUI/OidcConfiguration/OidcConfiguration.cs deleted file mode 100644 index 419b2b3d5..000000000 --- a/src/WebUI/OidcConfiguration/OidcConfiguration.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.AspNetCore.ApiAuthorization.IdentityServer; -using Microsoft.AspNetCore.Mvc; - -namespace CleanArchitecture.WebUI.OidcConfiguration; - -public class OidcConfiguration : AbstractEndpoint -{ - public override void Map(WebApplication app) - { - MapGet(app, "/_configuration/{clientId}", (IClientRequestParametersProvider clientRequestParametersProvider, HttpContext context, string clientId) => - { - var parameters = clientRequestParametersProvider.GetClientParameters(context, clientId); - return Results.Ok(parameters); - }, withDefaults: false).ExcludeFromDescription(); - } -} \ No newline at end of file diff --git a/src/WebUI/Program.cs b/src/WebUI/Program.cs index 5a5ed9b28..362e6760a 100644 --- a/src/WebUI/Program.cs +++ b/src/WebUI/Program.cs @@ -1,5 +1,4 @@ using CleanArchitecture.Infrastructure.Persistence; -using CleanArchitecture.WebUI; var builder = WebApplication.CreateBuilder(args); @@ -39,12 +38,6 @@ settings.DocumentPath = "/api/specification.json"; }); -app.UseRouting(); - -app.UseAuthentication(); -app.UseIdentityServer(); -app.UseAuthorization(); - app.MapControllerRoute( name: "default", pattern: "{controller}/{action=Index}/{id?}"); diff --git a/src/WebUI/wwwroot/api/specification.json b/src/WebUI/wwwroot/api/specification.json index 47af502a5..0fa8b49e5 100644 --- a/src/WebUI/wwwroot/api/specification.json +++ b/src/WebUI/wwwroot/api/specification.json @@ -1,5 +1,5 @@ { - "x-generator": "NSwag v13.17.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v13.0.0.0))", + "x-generator": "NSwag v13.19.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v10.0.0.0))", "openapi": "3.0.0", "info": { "title": "CleanArchitecture API", @@ -198,12 +198,7 @@ } } } - }, - "security": [ - { - "JWT": [] - } - ] + } } }, "/api/TodoItems/{id}": { @@ -302,12 +297,7 @@ "200": { "description": "" } - }, - "security": [ - { - "JWT": [] - } - ] + } } } }, @@ -352,7 +342,7 @@ "priorityLevels": { "type": "array", "items": { - "$ref": "#/components/schemas/PriorityLevelDto" + "$ref": "#/components/schemas/LookupDto" } }, "lists": { @@ -363,15 +353,15 @@ } } }, - "PriorityLevelDto": { + "LookupDto": { "type": "object", "additionalProperties": false, "properties": { - "value": { + "id": { "type": "integer", "format": "int32" }, - "name": { + "title": { "type": "string", "nullable": true } @@ -513,10 +503,5 @@ ] } } - }, - "security": [ - { - "JWT": [] - } - ] + } } \ No newline at end of file