canton7 / RestEase

Easy-to-use typesafe REST API client library for .NET Standard 1.1 and .NET Framework 4.5 and higher, which is simple and customisable. Inspired by Refit
MIT License
1.08k stars 109 forks source link

Define the "value" in a Variable Query Parameter which is defined on the interface #212

Open StefH opened 2 years ago

StefH commented 2 years ago

Description I've defined a query parameter on an interface like this:

public interface IApi
{
    [Query("api-version")]
    string ApiVersion { get; set; }

    [Get("users")]
    Task<List<User>> GetUsersAsync();
}

What I would to do is set the value for this Query Parameter like this:

public interface IApi
{
    [Query("api-version", "abc")]
    string ApiVersion { get; set; }

    [Get("users")]
    Task<List<User>> GetUsersAsync();
}

This makes the code more clean then just adding ?api-version=abc to every method like described here: https://github.com/canton7/RestEase#constant-query-parameters

Version Info

canton7 commented 2 years ago

This basically means extending the Header attribute model to query parameters. It's do-able (and I think I started down this route at some point, before it got complex and I realised noone was asking for it, at that point)

StefH commented 2 years ago

It would be useful to have this.

It makes the API more clean.