Skip to content

Commit f3a3292

Browse files
authored
Merge pull request #652 from bcgov/yj
Yj
2 parents 2c92056 + 1e8b1db commit f3a3292

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

server/StrDss.Api/Program.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using Microsoft.Extensions.Options;
2222
using Swashbuckle.AspNetCore.SwaggerGen;
2323
using StrDss.Common;
24+
using Microsoft.OpenApi.Models;
2425

2526
var builder = WebApplication.CreateBuilder(args);
2627

@@ -168,6 +169,30 @@
168169
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
169170
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
170171
options.IncludeXmlComments(xmlPath);
172+
173+
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
174+
{
175+
Type = SecuritySchemeType.Http,
176+
Scheme = "bearer",
177+
BearerFormat = "JWT",
178+
Description = "JWT Authorization header using the Bearer scheme. Enter 'Bearer' [space] and then your token in the text input below.",
179+
});
180+
181+
// Apply the security scheme to all operations
182+
options.AddSecurityRequirement(new OpenApiSecurityRequirement
183+
{
184+
{
185+
new OpenApiSecurityScheme
186+
{
187+
Reference = new OpenApiReference
188+
{
189+
Type = ReferenceType.SecurityScheme,
190+
Id = "Bearer"
191+
}
192+
},
193+
Array.Empty<string>()
194+
}
195+
});
171196
});
172197

173198
var healthCheck = new HealthCheck(connString);

server/StrDss.Api/SwaggerDocumentFilter.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
1818

1919
if (operation != null && operation.Tags.Any(t => Common.ApiTags.ApsTagList.Contains(t.Name)))
2020
{
21-
filteredPaths.Add(path.Key, path.Value);
21+
filteredPaths.Add(path.Key.ToLowerInvariant(), path.Value);
2222
TrackSchemasInOperations(operation, referencedSchemas);
2323
}
2424
}
25+
26+
//swaggerDoc.Servers = new List<OpenApiServer>
27+
//{
28+
// new OpenApiServer { Url = "https://strdata.dev.api.gov.bc.ca" }
29+
//};
2530
}
2631
else
2732
{

0 commit comments

Comments
 (0)