using Web.Api.Common;
using Microsoft.OpenApi;

namespace Web.Api;

public static class DependencyInjection
{
    public static IServiceCollection AddPresentation(this IServiceCollection services)
    {
        services.AddExceptionHandler<GlobalExceptionHandler>();
        services.AddProblemDetails();

        services.AddEndpointsApiExplorer();
        services.AddSwaggerGen(options =>
        {
            options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
            {
                Type = SecuritySchemeType.Http,
                Scheme = "bearer",
                BearerFormat = "JWT",
                Description = "JWT 토큰을 입력하세요."
            });

            options.AddSecurityRequirement(document => new() { [new OpenApiSecuritySchemeReference("bearer", document)] = [] });
        });

        return services;
    }
}