using AutobusApi.Infrastructure; using AutobusApi.Application; using AutobusApi.Api.Middlewares; using AutoubsApi.Infrastructure.Data; using AutobusApi.Infrastructure.Identity; using Microsoft.OpenApi.Models; using AutobusApi.Api.OpenApi; var builder = WebApplication.CreateBuilder(args); builder.Services.AddInfrastructure(builder.Configuration); builder.Services.AddApplication(); builder.Services.AddControllers(); builder.Services.AddSwaggerGen(options => { options.SchemaFilter(); options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { Scheme = "Bearer", BearerFormat = "Jwt", In = ParameterLocation.Header, Name = "Authorization", Description = "Bearer Authentication With Jwt", Type = SecuritySchemeType.Http }); options.AddSecurityRequirement(new OpenApiSecurityRequirement { { new OpenApiSecurityScheme { Reference = new OpenApiReference { Id = "Bearer", Type = ReferenceType.SecurityScheme } }, new List() } }); }); builder.Services.AddTransient(); var app = builder.Build(); // Initialize database var scope = app.Services.CreateScope(); var dbContext = scope.ServiceProvider.GetRequiredService(); var identityDbContext = scope.ServiceProvider.GetRequiredService(); DbInitializer.Initialize(dbContext, identityDbContext); app.UseAuthentication(); app.MapControllers(); app.UseSwagger(); app.UseSwaggerUI(); app.UseMiddleware(); app.Run(); public partial class Program { }