using Infrastructure; using Microsoft.EntityFrameworkCore; using Server.IServices; using Asp.Versioning; using Server.Services; using Microsoft.OpenApi.Models; using Infrastructure.Repositories; using AutoMapper; using Server.Mappers; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddControllers(); builder.Services.AddDbContext(options => options.UseSqlite("Data Source=../Server/FirstTest.db", b => b.MigrationsAssembly("Infrastructure"))); // Register AutoMapper builder.Services.AddAutoMapper(typeof(UserProfile)); builder.Services.AddAutoMapper(typeof(ExerciceProfile)); builder.Services.AddAutoMapper(typeof(SessionProfile)); builder.Services.AddAutoMapper(typeof(PaginatedResultProfile)); builder.Services.AddAutoMapper(typeof(TrainingProgramProfile)); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); // Add API's versioning builder.Services.AddApiVersioning(options => { options.DefaultApiVersion = new ApiVersion(1, 0); options.AssumeDefaultVersionWhenUnspecified = true; options.ReportApiVersions = true; }) .AddApiExplorer(options => { options.GroupNameFormat = "'v'VVV"; options.SubstituteApiVersionInUrl = true; }); builder.Services.AddSwaggerGen(c => c.SwaggerDoc("v1", new OpenApiInfo { Title = "Optifit API", Version = "v1" }) ); builder.Services.AddRouting(options => options.LowercaseUrls = true); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Optifit API v1"); c.RoutePrefix = string.Empty; // Serve Swagger UI at the app's root }); app.UseHttpsRedirection(); } app.UseAuthorization(); app.MapControllers(); app.Run();