using Microsoft.OpenApi;
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 (WGS84, decimal degrees, [-90, 90])",
            ["lon"] = "Longitude coordinate (WGS84, decimal degrees, [-180, 180])",
            ["zoom"] = "Slippy-map zoom level [0, 22] (higher = more detail)",
            ["mgrs"] = "MGRS coordinate string",
            ["squareSideMeters"] = "Square side size in meters"
        };

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