using Microsoft.OpenApi.Models; using ExpenseTracker.Api.Middlewares; using ExpenseTracker.Infrastructure; using ExpenseTracker.Application; using ExpenseTracker.Persistence; using ExpenseTracker.Infrastructure.Identity; using ExpenseTracker.Api.Services; using ExpenseTracker.Application.Common.Interfaces.Services; using ExpenseTracker.Api.Swashbuckle.OperationFilters; var builder = WebApplication.CreateBuilder(args); builder.Services.AddPersistence(builder.Configuration); builder.Services.AddInfrastructure(builder.Configuration); builder.Services.AddApplication(); builder.Services.AddAuthorization(); builder.Services.AddControllers(); builder.Services.AddSwaggerGen(options => { options.OperationFilter(); options.EnableAnnotations(); options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { Scheme = "Bearer", BearerFormat = "Json Web Token", In = ParameterLocation.Header, Name = "Authorization", Description = "Bearer Authentication With Json Web Token", Type = SecuritySchemeType.Http }); options.AddSecurityRequirement(new OpenApiSecurityRequirement { { new OpenApiSecurityScheme { Reference = new OpenApiReference { Id = "Bearer", Type = ReferenceType.SecurityScheme } }, new List() } }); }); builder.Services.AddTransient(); builder.Services.AddScoped(); builder.Services.AddScoped(); var app = builder.Build(); app.UseAuthentication(); app.UseAuthorization(); app.UseMiddleware(); app.MapControllers(); app.UseSwagger(); app.UseSwaggerUI(); var scope = app.Services.CreateScope(); IdentitySeeder.SeedIdentity(scope); app.Run();