initial upload
This commit is contained in:
parent
a0aa9cc28e
commit
f857f43df4
553 changed files with 46169 additions and 13 deletions
59
src/Api/Insight.Api/Extensions/ServiceExtensions.cs
Normal file
59
src/Api/Insight.Api/Extensions/ServiceExtensions.cs
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Insight.Api.Hosting
|
||||
{
|
||||
public static class ServiceExtensions
|
||||
{
|
||||
internal static IServiceCollection AddSwaggerServices(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddEndpointsApiExplorer();
|
||||
services.AddSwaggerGen(options =>
|
||||
{
|
||||
options.SwaggerDoc("v1", new OpenApiInfo
|
||||
{
|
||||
Title = "Insight API",
|
||||
Version = "v1"
|
||||
});
|
||||
|
||||
options.AddSecurityDefinition(name: "Bearer", securityScheme: new OpenApiSecurityScheme
|
||||
{
|
||||
Name = "Authorization",
|
||||
Description = "Enter the Bearer Authorization string as following: `Bearer Generated-JWT-Token`",
|
||||
In = ParameterLocation.Header,
|
||||
Type = SecuritySchemeType.ApiKey,
|
||||
Scheme = "Bearer",
|
||||
BearerFormat = "JWT",
|
||||
|
||||
Reference = new OpenApiReference
|
||||
{
|
||||
Id = JwtBearerDefaults.AuthenticationScheme,
|
||||
Type = ReferenceType.SecurityScheme
|
||||
}
|
||||
});
|
||||
|
||||
options.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||
{
|
||||
{
|
||||
new OpenApiSecurityScheme
|
||||
{
|
||||
In = ParameterLocation.Header,
|
||||
Reference = new OpenApiReference
|
||||
{
|
||||
Id = "Bearer",
|
||||
Type = ReferenceType.SecurityScheme
|
||||
}
|
||||
},
|
||||
new List<string>()
|
||||
}
|
||||
});
|
||||
|
||||
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue