using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;

namespace SatelliteProvider.Api.Swagger;

public class ParameterDescriptionFilter : IOperationFilter
{
    public void Apply(OpenApiOperation operation, OperationFilterContext context)
    {
        if (operation.Parameters == null) return;

        var parameterDescriptions = new Dictionary<string, string>
        {
            ["lat"] = "Latitude coordinate where image was captured",
            ["lon"] = "Longitude coordinate where image was captured",
            ["mgrs"] = "MGRS coordinate string",
            ["squareSideMeters"] = "Square side size in meters",
            ["Latitude"] = "Latitude coordinate of the tile center",
            ["Longitude"] = "Longitude coordinate of the tile center",
            ["ZoomLevel"] = "Zoom level for the tile (higher values = more detail)"
        };

        foreach (var parameter in operation.Parameters)
        {
            if (parameterDescriptions.TryGetValue(parameter.Name, out var description))
            {
                parameter.Description = description;
            }
        }
    }
}
