using System.Reflection;
using Microsoft.OpenApi;
namespace eSuite.API.Swagger;
internal static class SwaggerExtension
{
///
/// Adds support for Swagger documentation.
///
///
public static void AddSwagger(this WebApplicationBuilder builder)
{
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(options =>
{
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "e-suite API",
Description = "The RESTful Web API for e-suite",
//TermsOfService = new Uri("https://example.com/terms"),
//Contact = new OpenApiContact
//{
// Name = "Example Contact",
// Url = new Uri("https://example.com/contact")
//},
//License = new OpenApiLicense
//{
// Name = "License",
// Url = new Uri("https://example.com/license")
//}
});
options.OperationFilter();
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
In = ParameterLocation.Header,
Description = "Please insert JWT with \"Bearer \" into field",
Name = "Authorization",
Type = SecuritySchemeType.ApiKey,
BearerFormat = "Bearer JWT"
});
}
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
}
);
}
}