TFS_ANTIGUO/TPAtesa_CuentasCobrar/CuentasCobrar.API/Installers/SwaggerInstaller.cs

46 lines
1.7 KiB
C#

using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.Filters;
using System.Reflection;
namespace CuentasCobrar.API.Installers
{
public class SwaggerInstaller : IInstaller
{
public void InstallServices(IServiceCollection services, IConfiguration configuration)
{
//Configure Swagger
// Set the comments path for the Swagger JSON and UI.
services.AddSwaggerGen(doc =>
{
doc.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "Cuentas Por Cobrar Documentación",
Description = "REST API para la Aplicacion Cuentas Por Cobrar by: CR. ATESA S.A.",
//TermsOfService = new Uri("https://www.isystemcorp.io/terms"),
Contact = new OpenApiContact
{
Name = "CR. ATESA S.A.",
Email = "servicioalcliente@atesacr.com",
},
});
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
doc.IncludeXmlComments(xmlPath);
doc.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme
{
Description = "Standar Authorization header using the Bearer scheme (\"bearer {token}\")",
In = ParameterLocation.Header,
Name = "Authorization",
Type = SecuritySchemeType.ApiKey
});
doc.OperationFilter<SecurityRequirementsOperationFilter>();
});
}
}
}