From bc478814f2fdc231099aa96949bcd9fe9193b94f Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Tue, 30 Dec 2025 14:52:38 +0000 Subject: [PATCH 1/4] fix number of lines issue --- .../Bootstrapper/MiddlewareRegistry.cs | 64 +++++++------------ 1 file changed, 24 insertions(+), 40 deletions(-) diff --git a/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs b/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs index 005ed29..8502117 100644 --- a/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs +++ b/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs @@ -1,6 +1,8 @@ using KurrentDB.Client; using Microsoft.Extensions.Logging; using Microsoft.OpenApi; +using Shared.Extensions; +using Swashbuckle.AspNetCore.SwaggerGen; namespace CallbackHandler.Bootstrapper; @@ -32,40 +34,10 @@ public MiddlewareRegistry() String connectionString = Startup.Configuration.GetValue("EventStoreSettings:ConnectionString"); KurrentDBClientSettings eventStoreSettings = KurrentDBClientSettings.Create(connectionString); - this.AddHealthChecks().AddEventStore(eventStoreSettings, - userCredentials: eventStoreSettings.DefaultCredentials, - name: "Eventstore", - failureStatus: HealthStatus.Unhealthy, - tags: new[] { "db", "eventstore" }); + this.AddHealthChecks().AddTransactionProcessorService().AddEventStore(eventStoreSettings, userCredentials: eventStoreSettings.DefaultCredentials, + name: "Eventstore", failureStatus: HealthStatus.Unhealthy, tags: new[] { "db", "eventstore" }); - this.AddSwaggerGen(c => - { - c.SwaggerDoc("v1", new OpenApiInfo - { - Title = "Callback Handler API", - Version = "1.0", - Description = "A REST Api to handle callback requests from external parties API's.", - Contact = new OpenApiContact - { - Name = "Stuart Ferguson", - Email = "golfhandicapping@btinternet.com" - } - }); - // add a custom operation filter which sets default values - c.OperationFilter(); - c.ExampleFilters(); - - //Locate the XML files being generated by ASP.NET... - DirectoryInfo directory = new(AppContext.BaseDirectory); - FileInfo[] xmlFiles = directory.GetFiles("*.xml"); - - //... and tell Swagger to use those XML comments. - foreach (FileInfo fileInfo in xmlFiles) - { - c.IncludeXmlComments(fileInfo.FullName); - } - - }); + this.AddSwaggerGen(AddSwaggerAction); this.AddSwaggerExamples(); this.AddControllers().AddNewtonsoftJson(options => @@ -83,16 +55,28 @@ public MiddlewareRegistry() bool logRequests = ConfigurationReader.GetValueOrDefault("MiddlewareLogging", "LogRequests", true); bool logResponses = ConfigurationReader.GetValueOrDefault("MiddlewareLogging", "LogResponses", true); LogLevel middlewareLogLevel = ConfigurationReader.GetValueOrDefault("MiddlewareLogging", "MiddlewareLogLevel", LogLevel.Warning); + + this.AddSingleton(new RequestResponseMiddlewareLoggingConfig(middlewareLogLevel, logRequests, logResponses)); - RequestResponseMiddlewareLoggingConfig config = - new(middlewareLogLevel, logRequests, logResponses); - - this.AddSingleton(config); - - this.ConfigureHttpJsonOptions(options => - { + this.ConfigureHttpJsonOptions(options => { options.SerializerOptions.PropertyNamingPolicy = new SnakeCaseNamingPolicy(); options.SerializerOptions.PropertyNameCaseInsensitive = true; // optional, but safer }); } + + private void AddSwaggerAction(SwaggerGenOptions c) { + c.SwaggerDoc("v1", new OpenApiInfo { Title = "Callback Handler API", Version = "1.0", Description = "A REST Api to handle callback requests from external parties API's.", Contact = new OpenApiContact { Name = "Stuart Ferguson", Email = "golfhandicapping@btinternet.com" } }); + // add a custom operation filter which sets default values + c.OperationFilter(); + c.ExampleFilters(); + + //Locate the XML files being generated by ASP.NET... + DirectoryInfo directory = new(AppContext.BaseDirectory); + FileInfo[] xmlFiles = directory.GetFiles("*.xml"); + + //... and tell Swagger to use those XML comments. + foreach (FileInfo fileInfo in xmlFiles) { + c.IncludeXmlComments(fileInfo.FullName); + } + } } From 9bf5771f5382d0bd79b7650e17a0a2f3f61eee0b Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Wed, 31 Dec 2025 17:15:14 +0000 Subject: [PATCH 2/4] fix test failure --- CallbackHandler.Tests/BootstrapperTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/CallbackHandler.Tests/BootstrapperTests.cs b/CallbackHandler.Tests/BootstrapperTests.cs index aa922f9..abbacb1 100644 --- a/CallbackHandler.Tests/BootstrapperTests.cs +++ b/CallbackHandler.Tests/BootstrapperTests.cs @@ -48,6 +48,7 @@ private IConfigurationRoot SetupMemoryConfiguration() configuration.Add("AppSettings:SecurityService", "http://127.0.0.1"); configuration.Add("AppSettings:MessagingServiceApi", "http://127.0.0.1"); configuration.Add("AppSettings:DatabaseEngine", "SqlServer"); + configuration.Add("AppSettings:TransactionProcessorApi","http://127.0.0.1"); builder.AddInMemoryCollection(configuration); From 4e730da91439deecda2c425675cd8b1d32c25782 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Wed, 31 Dec 2025 17:19:53 +0000 Subject: [PATCH 3/4] oops --- CallbackHander.Testing/TestData.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/CallbackHander.Testing/TestData.cs b/CallbackHander.Testing/TestData.cs index f1b2f8e..62c4eac 100644 --- a/CallbackHander.Testing/TestData.cs +++ b/CallbackHander.Testing/TestData.cs @@ -39,6 +39,7 @@ public static TokenResponse TokenResponse() ["SecurityConfiguration:Authority"] = "https://127.0.0.1", ["AppSettings:EstateManagementApi"] = "http://127.0.0.1", ["AppSettings:SecurityService"] = "http://127.0.0.1", + ["AppSettings:TransactionProcessorApi"] = "http://127.0.0.1", ["AppSettings:ContractProductFeeCacheExpiryInHours"] = "", ["AppSettings:ContractProductFeeCacheEnabled"] = "", ["ConnectionStrings:HealthCheck"] = "HealthCheck", From 8321664281e09db63bb57da1e1c6f22169d8e352 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Wed, 31 Dec 2025 19:16:22 +0000 Subject: [PATCH 4/4] :| --- CallbackHandler/Bootstrapper/MiddlewareRegistry.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs b/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs index 8502117..7a13701 100644 --- a/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs +++ b/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs @@ -34,7 +34,7 @@ public MiddlewareRegistry() String connectionString = Startup.Configuration.GetValue("EventStoreSettings:ConnectionString"); KurrentDBClientSettings eventStoreSettings = KurrentDBClientSettings.Create(connectionString); - this.AddHealthChecks().AddTransactionProcessorService().AddEventStore(eventStoreSettings, userCredentials: eventStoreSettings.DefaultCredentials, + this.AddHealthChecks().AddEventStore(eventStoreSettings, userCredentials: eventStoreSettings.DefaultCredentials, name: "Eventstore", failureStatus: HealthStatus.Unhealthy, tags: new[] { "db", "eventstore" }); this.AddSwaggerGen(AddSwaggerAction);