Provides attributes that are used to SourceGeneratorPower HttpClient
$ dotnet add package SourceGeneratorPower.HttpClient.AbstractionsSourceGeneratorPower.HttpClient is used C# roslyn's Source Generator feature to auto implement HTTP API Caller interface, It depends on IHttpClientFactory to create HttpClient to sending request and receive response with System.Text.Json.
dotnet add package SourceGeneratorPower.HttpClient.Abstractions
dotnet add package SourceGeneratorPower.HttpClient.SourceGenerator
[HttpClient("JsonServer")]
public interface IJsonServerApi
{
[HttpGet("/todos/{id}")]
Task<Todo> Get(int id, CancellationToken cancellationToken = default);
}
builder.Services.AddGeneratedHttpClient();
builder.Services.AddHttpClient("JsonServer", options => options.BaseAddress = new Uri("https://jsonplaceholder.typicode.com"));
More attribute using in string interpolation
RequiredServiceAttribute
UsingAttribute
Then build solution
v1.1.3
global::