diff --git a/server/ConfigureSwaggerOptions.cs b/server/ConfigureSwaggerOptions.cs index 93c825e..f338101 100644 --- a/server/ConfigureSwaggerOptions.cs +++ b/server/ConfigureSwaggerOptions.cs @@ -4,7 +4,7 @@ namespace Sockeye using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; - using Microsoft.OpenApi.Models; + using Microsoft.OpenApi; using Swashbuckle.AspNetCore.SwaggerGen; using System; diff --git a/server/Controllers/HealthController.cs b/server/Controllers/HealthController.cs index bcbbbed..00bdaa4 100644 --- a/server/Controllers/HealthController.cs +++ b/server/Controllers/HealthController.cs @@ -37,7 +37,7 @@ namespace Sockeye.Api.Controllers public async Task Get() { var report = await _healthCheckService.CheckHealthAsync(); - Response.Headers.Add("Cache-Control", "no-store, no-cache"); + Response.Headers.Append("Cache-Control", "no-store, no-cache"); return report.Status == HealthStatus.Healthy ? Ok(report.Status.ToString()) : StatusCode(503, report.Status.ToString()); } }//eoc diff --git a/server/Startup.cs b/server/Startup.cs index 5006baf..1b343bc 100644 --- a/server/Startup.cs +++ b/server/Startup.cs @@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Tokens; using Microsoft.Extensions.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi; using Microsoft.Extensions.Options; using Swashbuckle.AspNetCore.SwaggerGen; @@ -253,16 +253,23 @@ namespace Sockeye Scheme = "bearer" //The name of the HTTP Authorization scheme to be used in the Authorization header. In this case "bearer". }); - c.AddSecurityRequirement(new OpenApiSecurityRequirement{ - { - new OpenApiSecurityScheme{ - Reference = new OpenApiReference{ - Id = "Bearer", //The name of the previously defined security scheme. - Type = ReferenceType.SecurityScheme - } - },new List() - } - }); + // c.AddSecurityRequirement(new OpenApiSecurityRequirement{ + // { + // new OpenApiSecurityScheme{ + // Reference = new OpenApiReference{ + // Id = "Bearer", //The name of the previously defined security scheme. + // Type = ReferenceType.SecurityScheme + // } + // },new List() + // } + // }); + + c.AddSecurityRequirement(document => new OpenApiSecurityRequirement + { + // "Bearer" must match the name given to AddSecurityDefinition above + [new OpenApiSecuritySchemeReference("Bearer", document)] = [] + }); + } ); services.AddSwaggerGenNewtonsoftSupport(); @@ -529,7 +536,7 @@ namespace Sockeye if (!bLocalReportRenderRequest) { context.Response.StatusCode = 401; - context.Response.Headers.Add("X-Sockeye-Authorization-Error", "E2004 - Authorization token replaced by more recent login"); + context.Response.Headers.Append("X-Sockeye-Authorization-Error", "E2004 - Authorization token replaced by more recent login"); await context.Response.WriteAsync("E2004 - Authorization token replaced by more recent login"); } } diff --git a/server/sockeye.csproj b/server/sockeye.csproj index 2281949..845ed95 100644 --- a/server/sockeye.csproj +++ b/server/sockeye.csproj @@ -18,35 +18,32 @@ - + + - - + + - - + + - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - - - + + + + + - - - - - - - - + + + + +