Remora.Rest.Xunit
2.0.1
Prefix Reserved
See the version list below for details.
dotnet add package Remora.Rest.Xunit --version 2.0.1
NuGet\Install-Package Remora.Rest.Xunit -Version 2.0.1
<PackageReference Include="Remora.Rest.Xunit" Version="2.0.1" />
paket add Remora.Rest.Xunit --version 2.0.1
#r "nuget: Remora.Rest.Xunit, 2.0.1"
// Install Remora.Rest.Xunit as a Cake Addin #addin nuget:?package=Remora.Rest.Xunit&version=2.0.1 // Install Remora.Rest.Xunit as a Cake Tool #tool nuget:?package=Remora.Rest.Xunit&version=2.0.1
Remora.Rest
Remora.Rest is a compact helper library for building REST API wrappers, giving you the tools you need to rapidly create robust, highly configurable wrappers of your own.
The library is somewhat opinionated, and it does target a single subset of REST API types - those whose payloads (error or otherwise) are JSON-serialized. For these use cases, however, the library is quite adept at what it does.
Quickstart
At its core, the library expects you to do two things - one, to access the REST
endpoints through a configured RestHttpClient<TError>
, and two, to define the
entities in the API model through an interface/implementation combination.
var services = new ServiceCollection();
var clientBuilder = services
.AddRestHttpClient<RestHttpClient<ErrorPayloadType>>();
// Perform HttpClient configuration (adding Polly policies, setting default
// request headers, etc)
clientBuilder...
// Configure API model types
services.Configure<JsonSerializerOptions>(clientBuilder.Name, options =>
{
options.AddDataObjectConverter<IModelType, ModelType>();
});
After you've set up your client and your types, you can then inject an instance
of RestHttpClient<TError>
into your actual API wrapper type (the instance is
transient, so you can treat it the same as any HttpClient you'd normally
inject).
public class MyWrapper
{
private readonly RestHttpClient<ErrorPayloadType> _restClient;
public MyWrapper(RestHttpClient<ErrorPayloadType> restClient)
{
_restClient = restClient;
}
}
More detailed documentation will hopefully be available in the future; in the meantime, check out Remora.Discord, for which this project was originally developed - it pushes all available functionality to its limits, and serves as a relatively comprehensive demonstration of what you can do with the library.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- RichardSzalay.MockHttp (>= 6.0.0)
- System.Text.Json (>= 7.0.0)
- xunit.assert (>= 2.4.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Remora.Rest.Xunit:
Repository | Stars |
---|---|
Remora/Remora.Discord
A data-oriented C# Discord library, focused on high-performance concurrency and robust design.
|
Version | Downloads | Last updated |
---|---|---|
3.0.4 | 395 | 3/31/2024 |
3.0.3 | 558 | 11/20/2023 |
3.0.1 | 234 | 9/10/2023 |
3.0.0 | 693 | 12/28/2022 |
2.0.1 | 496 | 11/20/2022 |
2.0.0 | 489 | 10/14/2022 |
1.2.1 | 520 | 8/19/2022 |
1.2.0 | 397 | 8/4/2022 |
1.1.0 | 396 | 8/3/2022 |
1.0.4 | 702 | 6/18/2022 |
1.0.3 | 796 | 4/19/2022 |
1.0.2 | 720 | 2/13/2022 |
1.0.1 | 2,092 | 11/26/2021 |
1.0.0 | 347 | 11/14/2021 |
Upgrade Remora.Sdk and nuget packages.