Skip to content

Commit

Permalink
TEST-0011 Add api client project
Browse files Browse the repository at this point in the history
  • Loading branch information
hwinther committed Nov 13, 2024
1 parent aabafb9 commit 2d92d39
Show file tree
Hide file tree
Showing 6 changed files with 476 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/backend/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
"dotnet-outdated"
],
"rollForward": false
},
"refitter": {
"version": "1.4.0",
"commands": [
"refitter"
],
"rollForward": false
}
}
}
19 changes: 19 additions & 0 deletions src/backend/ApiClient/ApiClient.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<Target Name="RefitGenerator" BeforeTargets="build" Condition="'$(Configuration)' == 'Debug'">
<Warning Code="DSAMPLE002" Text="Generating API client with refitter" />
<Exec Command="dotnet refitter ..\WebApi\swagger.json --namespace WebApi.Client --output WebApiClient.cs" />
</Target>

<ItemGroup>
<PackageReference Include="Refit" Version="8.0.0" />
</ItemGroup>

</Project>
5 changes: 5 additions & 0 deletions src/backend/ApiClient/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Refit;
using WebApi.Client;

var testApiClient = RestService.For<IExampleAPI>("https://localhost:44380");
await testApiClient.Ping();
Loading

0 comments on commit 2d92d39

Please sign in to comment.