Skip to content

Refit 2.1.0

Compare
Choose a tag to compare
@anaisbetts anaisbetts released this 14 Nov 05:03
· 1603 commits to main since this release

What's New

Generic Interface Support (#70)

Thanks to @bennor, you can now define generic interfaces that apply to multiple APIs:

public interface IReallyExcitingCrudApi<T, in TKey> where T : class
{
    [Post("")]
    Task<T> Create([Body] T paylod);

    [Get("")]
    Task<List<T>> ReadAll();

    [Get("/{key}")]
    Task<T> ReadOne(TKey key);

    [Put("/{key}")]
    Task Update(TKey key, [Body]T payload);

    [Delete("/{key}")]
    Task Delete(TKey key);
}

// Later, in another part of town...
var userApi = RestService.For<IReallyExcitingCrudApi<User, string>>("http://api.example.com/users"); 
var adminApi = RestService.For<IReallyExcitingCrudApi<Admin, string>>("http://api.example.com/admins"); 

URL Parameter Formatting (#66)

Thanks to @carl-berg, types that are serialized in the URL query string can now define custom formatting, via a new RefitSettings class that is optionally passed to RestService.For.

Bug Fixes / Improvements

  • URL parameters are now no longer case-sensitive (#68, thanks @flagbug)
  • Refit Interfaces which were defined in different assemblies than where they were used will now correctly get stubs generated (#67, thanks @bennor)
  • Type aliases will now be recognized in interfaces (#62, thanks @bennor)