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", 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); diff --git a/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs b/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs index 005ed29..7a13701 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().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); + } + } }