{"id":31282215,"url":"https://github.com/beffyman/aspnetcore.client","last_synced_at":"2025-09-24T03:43:01.320Z","repository":{"id":40416336,"uuid":"138951204","full_name":"Beffyman/AspNetCore.Client","owner":"Beffyman","description":"On Build client generator for asp.net core projects","archived":false,"fork":false,"pushed_at":"2022-05-10T03:54:25.000Z","size":1336,"stargazers_count":15,"open_issues_count":17,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-09-22T15:30:52.287Z","etag":null,"topics":["aspnetcore","azure-functions","blazor","c-sharp","dotnet","dotnet-core","generator","httpclient","signalr"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Beffyman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-28T01:31:24.000Z","updated_at":"2024-02-02T18:10:17.000Z","dependencies_parsed_at":"2022-08-09T19:50:27.020Z","dependency_job_id":null,"html_url":"https://github.com/Beffyman/AspNetCore.Client","commit_stats":null,"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"purl":"pkg:github/Beffyman/AspNetCore.Client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beffyman%2FAspNetCore.Client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beffyman%2FAspNetCore.Client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beffyman%2FAspNetCore.Client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beffyman%2FAspNetCore.Client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Beffyman","download_url":"https://codeload.github.com/Beffyman/AspNetCore.Client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beffyman%2FAspNetCore.Client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276689016,"owners_count":25686611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-24T02:00:09.776Z","response_time":97,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspnetcore","azure-functions","blazor","c-sharp","dotnet","dotnet-core","generator","httpclient","signalr"],"created_at":"2025-09-24T03:42:56.745Z","updated_at":"2025-09-24T03:43:01.311Z","avatar_url":"https://github.com/Beffyman.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Beffyman.AspNetCore.Client\r\n[![Build Status](https://dev.azure.com/beffyman/Beffyman.Github/_apis/build/status/Beffyman.AspNetCore.Client?branchName=master)](https://dev.azure.com/beffyman/Beffyman.Github/_build/latest?definitionId=7\u0026branchName=master)\r\n---\r\n\r\nIf you are anything like me, you look at\r\n\r\n```c#\r\nusing(var client = new HttpClient())\r\n{\r\n\tvar request = await client.GetAsync($\"api/mysuperspecialroute/{id}\");\r\n\t//Now to make sure what came back is what is expected, in every case...\r\n}\r\n```\r\nand think the following\r\n- Why not just inject clients?\r\n  - services.AddTestWebClients();!\r\n- How can I pool the HttpClient usage? \r\n  - HttpClient is injected! Which allows you to control it's lifecycle\r\n- Yuck, hard coded routes, these can lead to issues if my endpoint is still under development. \r\n  - Generated On Build! Beffyman.AspNetCore.Client.Generator is a before compile build task that will generate clients inside the project that implements it.\r\n- How do I unit test this without spinning up a full web app? \r\n  - Works with Microsoft.AspNetCore.TestHost!\r\n    - CancellationTokens are not respected inside the TestServer without some hacks though *(registering a kill of the server)* due to the Token not being checked.\r\n- How do I tell my teammates that an endpoint has headers it requires? \r\n  - HeaderParameterAttribute! Which makes a header a parameter inside the generated methods, which may or may not be required.\r\n  - IncludeHeaderAttribute! Which defines a constant header value to be included\r\n- How do I tell my teammates that an endpoint has known response types for status codes?\r\n  - ProducesResponseType! Generates action parameters that allow custom logic depending on the status code returned, without needing to manually check it.\r\n- What if sometimes I want to intercept requests before they go out? \r\n  - IHttpOverride! Which allows for potential cache interception of requests.\r\n- If I own the endpoint's code, why can't I just generate clients from it to make interacting with it as simple as injecting it?\r\n  - Introducing Beffyman.AspNetCore.Client.Generator!\r\n\r\n[First Time Setup](https://github.com/Beffyman/AspNetCore.Client/wiki/First-Time-Setup)\r\n\r\n## Supported Frameworks\r\n- AspNetCore 3.1 HTTP Controllers\r\n- AspNetCore 3.1 SignalR Hubs\r\n- AspNetCore 3.1 Blazor Client Side\r\n- Http Trigger Azure Functions v3\r\n\r\n## Beffyman.AspNetCore.Client\r\n[![NuGet](https://img.shields.io/nuget/v/Beffyman.AspNetCore.Client.svg)](https://www.nuget.org/packages/Beffyman.AspNetCore.Client)\r\n\r\nIncludes ServiceCollection registration logic, used on the Client\r\n\r\n## Beffyman.AspNetCore.Client.Generator\r\n[![NuGet](https://img.shields.io/nuget/v/Beffyman.AspNetCore.Client.Generator.svg)](https://www.nuget.org/packages/Beffyman.AspNetCore.Client.Generator)\r\n\r\nOn Build generator that will generate a Clients.cs file based on the Properties in the csproj.\r\n\r\n\r\n## Beffyman.AspNetCore.Server\r\n[![NuGet](https://img.shields.io/nuget/v/Beffyman.AspNetCore.Server.svg)](https://www.nuget.org/packages/Beffyman.AspNetCore.Server)\r\n\r\nIncludes attributes that can affect generation, used on your AspNetCore api app\r\n\r\n## Beffyman.AspNetCore.Client.Protobuf\r\n[![NuGet](https://img.shields.io/nuget/v/Beffyman.AspNetCore.Client.Protobuf.svg)](https://www.nuget.org/packages/Beffyman.AspNetCore.Client.Protobuf)\r\n\r\nContains a protobuf serializer which can override the default json one via the UseProtobufSerlaizer on the ClientConfiguration.\r\n\r\n```c#\r\nservices.AddTestWebClients(config=\u003e\r\n{\r\n\tconfig.UseProtobufSerializer()\r\n\t\t\t.UseProtobufDeserializer()\r\n\t\t\t.WithProtobufBody();\r\n});\r\n\r\n```\r\n\r\n\r\n## Beffyman.AspNetCore.Client.MessagePack\r\n[![NuGet](https://img.shields.io/nuget/v/Beffyman.AspNetCore.Client.MessagePack.svg)](https://www.nuget.org/packages/Beffyman.AspNetCore.Client.MessagePack)\r\n\r\nContains a MessagePack serializer which can override the default json one via the UseMessagePackSerializer on the ClientConfiguration.\r\n\r\nRequires version 1.7.3.7 at the moment due to https://github.com/dotnet/aspnetcore/issues/18074\r\n\r\n```c#\r\nservices.AddTestWebClients(config=\u003e\r\n{\r\n\tconfig.UseMessagePackSerializer()\r\n\t\t\t.UseMessagePackDeserializer()\r\n\t\t\t.WithMessagePackBody();\r\n});\r\n\r\n```\r\n\r\n\r\n## Beffyman.AspNetCore.Client.NewtonsoftJson\r\n[![NuGet](https://img.shields.io/nuget/v/Beffyman.AspNetCore.Client.NewtonsoftJson.svg)](https://www.nuget.org/packages/Beffyman.AspNetCore.Client.NewtonsoftJson)\r\n\r\nContains a Newtonsoft Json serializer which can override the default json one via the UseNewtonsoftJsonHttpSerializer on the ClientConfiguration.\r\n\r\n```c#\r\nservices.AddTestWebClients(config=\u003e\r\n{\r\n\tconfig.UseNewtonsoftJsonHttpSerializer()\r\n\t\t\t.UseNewtonsoftJsonHttpDeserializer()\r\n\t\t\t.WithJsonBody();\r\n});\r\n\r\n```\r\n\r\n\r\n## Beffyman.AspNetCore.Client.Http\r\n[![NuGet](https://img.shields.io/nuget/v/Beffyman.AspNetCore.Client.Http.svg)](https://www.nuget.org/packages/Beffyman.AspNetCore.Client.Http)\r\n\r\nUses Microsoft.Extensions.Http to inject a client factory. This allows for better reuse of the underlying HttpMessageHandler. \r\n\r\n```c#\r\nservices.AddTestWebClients(config=\u003e\r\n{\r\n\tconfig.UseHttpClientFactory\u003cITestWebAppClient\u003e();\r\n});\r\n\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeffyman%2Faspnetcore.client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeffyman%2Faspnetcore.client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeffyman%2Faspnetcore.client/lists"}