Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 31 additions & 23 deletions SecurityService/Bootstrapper/MiddlewareRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,34 @@
{
public MiddlewareRegistry()
{
if (Startup.WebHostEnvironment.IsEnvironment("IntegrationTest")){
this.ConfigureHealthChecks();
this.ConfigureSwagger();
this.AddSwaggerExamplesFromAssemblyOf<SwaggerJsonConverter>();

//this.AddRazorPages();

Check notice on line 32 in SecurityService/Bootstrapper/MiddlewareRegistry.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

SecurityService/Bootstrapper/MiddlewareRegistry.cs#L32

Remove this commented out code.
//this.AddControllers();
// .AddNewtonsoftJson(options =>
//{
// options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
// options.SerializerSettings.TypeNameHandling = TypeNameHandling.Auto;
// options.SerializerSettings.Formatting = Formatting.Indented;
// options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
// options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
//});

this.ConfigureHttpJsonOptions(options =>
{
options.SerializerOptions.PropertyNamingPolicy = new SnakeCaseNamingPolicy();
options.SerializerOptions.PropertyNameCaseInsensitive = true; // optional, but safer
});
}

private void ConfigureHealthChecks()
{
if (Startup.WebHostEnvironment.IsEnvironment("IntegrationTest")) {
this.AddHealthChecks();
}
else if (Startup.Configuration.GetValue<Boolean>("ServiceOptions:UseInMemoryDatabase")){
else if (Startup.Configuration.GetValue<Boolean>("ServiceOptions:UseInMemoryDatabase")) {
this.AddHealthChecks().AddMessagingService();
}
else
Expand All @@ -37,8 +61,8 @@
.AddMessagingService()
.AddSqlServer(ConfigurationReader.GetConnectionString("PersistedGrantDbContext"),
"SELECT 1;",
name:"Persisted Grant DB",
failureStatus:HealthStatus.Unhealthy,
name: "Persisted Grant DB",
failureStatus: HealthStatus.Unhealthy,
tags: new string[] { "db", "sql", "sqlserver", "persistedgrant" })
.AddSqlServer(ConfigurationReader.GetConnectionString("ConfigurationDbContext"),
"SELECT 1;",
Expand All @@ -51,7 +75,10 @@
failureStatus: HealthStatus.Unhealthy,
tags: new string[] { "db", "sql", "sqlserver", "authentication" });
}
}

private void ConfigureSwagger()
{
this.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo
Expand Down Expand Up @@ -79,25 +106,6 @@
c.IncludeXmlComments(fileInfo.FullName);
}
});

this.AddSwaggerExamplesFromAssemblyOf<SwaggerJsonConverter>();

//this.AddRazorPages();
//this.AddControllers();
// .AddNewtonsoftJson(options =>
//{
// options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
// options.SerializerSettings.TypeNameHandling = TypeNameHandling.Auto;
// options.SerializerSettings.Formatting = Formatting.Indented;
// options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
// options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
//});

this.ConfigureHttpJsonOptions(options =>
{
options.SerializerOptions.PropertyNamingPolicy = new SnakeCaseNamingPolicy();
options.SerializerOptions.PropertyNameCaseInsensitive = true; // optional, but safer
});
}
}

Expand Down
Loading