using Fest.WebApi;
using Fest.WebApi.Controllers;
using Fest.WebApi.DL;
using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models;

var builder = WebApplication.CreateBuilder(args);
string? connectionString = builder.Configuration.GetConnectionString("Default");

builder.Services.AddControllers();
builder.Services.AddDbContext<WeatherDbContext>(options => options.UseNpgsql(connectionString));
builder.Services.AddHttpClient<WeatherController>();
builder.Services.AddMvc();
builder.Services.AddSwaggerGen(c =>
{
    c.SwaggerDoc("v1", new OpenApiInfo { Title = "Fest weather API", Version = "v1" });
    c.OperationFilter<SwaggerXClientIdHeaderParameterOperationFilter>();
});

var app = builder.Build();

app.UseHttpsRedirection();
app.MapControllers();
app.UseSwagger();
app.UseSwaggerUI(c =>
{
    c.SwaggerEndpoint("v1/swagger.json", "Weather API V1");
});
app.Run();