Fluent.Unions.Refit 1.1.0

dotnet add package Fluent.Unions.Refit --version 1.1.0
                    
NuGet\Install-Package Fluent.Unions.Refit -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Fluent.Unions.Refit" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fluent.Unions.Refit" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Fluent.Unions.Refit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Fluent.Unions.Refit --version 1.1.0
                    
#r "nuget: Fluent.Unions.Refit, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Fluent.Unions.Refit@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Fluent.Unions.Refit&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Fluent.Unions.Refit&version=1.1.0
                    
Install as a Cake Tool

Fluent.Unions

Fluent.Unions.Refit

NuGet Downloads Publish Documentation

Converts Refit API responses to Result, Result<T> and Result<Option<T>>, so an HTTP error or a network failure becomes an error instead of an exception. It builds on Fluent.Unions and Refit (MIT), and works with the source-generated Refit clients, so it is trim and Native AOT safe.

Installation

dotnet add package Fluent.Unions.Refit

Usage

Declare the Refit method with IApiResponse<T>, which never throws for an HTTP error, and convert the call.

using Refit;
using Fluent.Unions.Refit;

public interface IUserApi
{
    [Get("/users/{id}")]
    Task<IApiResponse<User>> GetUser(int id, CancellationToken cancellationToken = default);

    [Delete("/users/{id}")]
    Task<IApiResponse> DeleteUser(int id, CancellationToken cancellationToken = default);
}

Result<User> user = await api.GetUser(7).ToResult();
// the user, or an ApiException (HTTP error) or an ApiRequestException (network failure) as the error

Result<Option<User>> maybe = await api.GetUser(7).ToOptionalResult();
// none for a 404, the user for a 2xx, an error for anything else

Result deleted = await api.DeleteUser(7).ToResult();

Cancellation and timeouts are thrown, never turned into an error. Task<ApiResponse<T>> works the same way, and ToResult() and ToOptionalResult() convert a response you already hold.

With your own result type

ToResult() and ToOptionalResult() produce the default Fluent.Unions.Result<T>. To get your own type, wrap the call in your own Result.TryAsync(...), or convert with Match. See your own result type.

Shop.Result<User> mine = user.Match(value => (Shop.Result<User>)value, error => DomainException.FromException(error));

Documentation

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 95 11/22/2026
1.0.0 98 11/21/2026
0.3.0 103 11/20/2026