Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Windows image file caches
Thumbs.db
Thumbs.db

# Folder config file
Desktop.ini
Expand Down Expand Up @@ -89,3 +89,5 @@ packages/
*.userprefs
Refit-Tests/test-results
/InterfaceStubGenerator.App/Properties/launchSettings.json

Refit.Tests/RefitStubs.*
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,31 @@ Task<List<Page>> Search(string page);
Search("admin/products");
>>> "/search/admin/products"
```

An interface or class may have HTTP attribute that are provided to all of its request method relative URLs by applaying BaseAddress annotations.

```csharp
interface IExample
{
[Get("/api/item/{id}")]
Task<Item> Get(string id);
}

Get("123");
>>> "/api/item/123"


[BaseAddress("/api/{tenantId}")]
interface IExampleWithBaseAddress
{
[Get("/item/{id}")]
Task<Item> Get(string tenantid, string id);
}

Get("tid-0087", "123");
>>> "/api/tid-0087/item/123"
```

### Dynamic Querystring Parameters

If you specify an `object` as a query parameter, all public properties which are not null are used as query parameters.
Expand Down
41 changes: 14 additions & 27 deletions Refit.Tests/Refit.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,44 +25,31 @@
</ItemGroup>
<ItemGroup>
<None Include="RefitStubs.*.cs" />
<Compile Condition="'$(TargetFramework)' == 'net461' " Remove="RefitStubs.NetCore2.cs" />
<Compile Condition="'$(TargetFramework)' == 'netcoreapp2.1' " Remove="RefitStubs.Net46.cs" />
<Compile Remove="RefitStubs.*.cs" />
</ItemGroup>

<Target Name="GenerateRefitStubsFull" Condition="'$(DesignTimeBuild)' != 'true' and '$(MSBuildRuntimeType)' != 'Core' " BeforeTargets="CoreCompile">
<Target Name="GenerateRefitStubs" Condition="'$(DesignTimeBuild)' != 'true' " BeforeTargets="BeforeCompile">
<PropertyGroup>
<OutputStubsFile Condition="'$(TargetFramework)' == 'net461' ">$(MSBuildThisFileDirectory)RefitStubs.Net46.cs</OutputStubsFile>
<OutputStubsFile Condition="'$(TargetFramework)' == 'netcoreapp2.1' ">$(MSBuildThisFileDirectory)RefitStubs.NetCore2.cs</OutputStubsFile>
<RefitStubExecPlatform Condition="'$(TargetFramework.StartsWith(&quot;net4&quot;))' != 'true' ">netcoreapp2.1</RefitStubExecPlatform>
<RefitStubExecPlatform Condition="'$(TargetFramework.StartsWith(&quot;net4&quot;))' == 'true' ">net461</RefitStubExecPlatform>
<OutputStubsFile>$(MSBuildThisFileDirectory)RefitStubs.$(TargetFramework).cs</OutputStubsFile>
<RefitParameterFile>$(MSBuildThisFileDirectory)$(IntermediateOutputPath)RefitParams.rsp</RefitParameterFile>
<RefitExecutableBase>$(MSBuildThisFileDirectory)../InterfaceStubGenerator.App/bin/$(ConfigurationName)/$(RefitStubExecPlatform)/InterfaceStubGenerator.App</RefitExecutableBase>
<RefitExecCmdParams>"$(OutputStubsFile)" "$(MSBuildProjectDirectory)" "$(RefitParameterFile)" "$(RootNamespace)"</RefitExecCmdParams>
</PropertyGroup>
<WriteLinesToFile File="$(RefitParameterFile)" Lines="@(Compile)" Overwrite="true" />
<PropertyGroup Condition="'$(OS)' == 'Windows_NT'">
<RefitExecCmd>"$(MSBuildThisFileDirectory)..\InterfaceStubGenerator.App\bin\$(ConfigurationName)\net461\InterfaceStubGenerator.App.exe" "$(OutputStubsFile)" "$(MSBuildProjectDirectory)" "$(RefitParameterFile)" "$(RootNamespace)"</RefitExecCmd>
</PropertyGroup>
<PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
<RefitExecCmd>mono "$(MSBuildThisFileDirectory)../InterfaceStubGenerator.App/bin/$(Configuration)/net461/InterfaceStubGenerator.App.exe" "$(OutputStubsFile)" "$(MSBuildProjectDirectory)" "$(RefitParameterFile)" "$(RootNamespace)"</RefitExecCmd>
</PropertyGroup>
<Message Text="Executing: $(RefitExecCmd)" Importance="High" />
<Exec Command="$(RefitExecCmd)" />
<Message Text="Processed Refit Stubs" />
</Target>

<Target Name="GenerateRefitStubsCore" Condition="'$(DesignTimeBuild)' != 'true' and '$(MSBuildRuntimeType)' == 'Core' " BeforeTargets="CoreCompile">
<PropertyGroup>
<OutputStubsFile Condition="'$(TargetFramework)' == 'net461' ">$(MSBuildThisFileDirectory)RefitStubs.Net46.cs</OutputStubsFile>
<OutputStubsFile Condition="'$(TargetFramework)' == 'netcoreapp2.1' ">$(MSBuildThisFileDirectory)RefitStubs.NetCore2.cs</OutputStubsFile>
<RefitParameterFile>$(MSBuildThisFileDirectory)$(IntermediateOutputPath)RefitParams.rsp</RefitParameterFile>
</PropertyGroup>
<WriteLinesToFile File="$(RefitParameterFile)" Lines="@(Compile)" Overwrite="true" />
<PropertyGroup Condition="'$(OS)' == 'Windows_NT'">
<RefitExecCmd>dotnet "$(MSBuildThisFileDirectory)..\InterfaceStubGenerator.App\bin\$(ConfigurationName)\netcoreapp2.1\InterfaceStubGenerator.App.dll" "$(OutputStubsFile)" "$(MSBuildProjectDirectory)" "$(RefitParameterFile)" "$(RootNamespace)"</RefitExecCmd>
</PropertyGroup>
<PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
<RefitExecCmd>dotnet "$(MSBuildThisFileDirectory)../InterfaceStubGenerator.App/bin/$(Configuration)/netcoreapp2.1/InterfaceStubGenerator.App.dll" "$(OutputStubsFile)" "$(MSBuildProjectDirectory)" "$(RefitParameterFile)" "$(RootNamespace)"</RefitExecCmd>
<RefitExecCmd Condition="'$(TargetFramework.StartsWith(&quot;net4&quot;))' != 'true' "
>dotnet "$(RefitExecutableBase.Replace('/', $([System.IO.Path]::DirectorySeparatorChar.ToString()))).dll" $(RefitExecCmdParams)</RefitExecCmd>
<RefitExecCmd Condition="'$(TargetFramework.StartsWith(&quot;net4&quot;))' == 'true' "
>"$(RefitExecutableBase.Replace(`/`, $([System.IO.Path]::DirectorySeparatorChar.ToString()))).exe" $(RefitExecCmdParams)</RefitExecCmd>
</PropertyGroup>
<Message Text="Executing: $(RefitExecCmd)" Importance="High" />
<Exec Command="$(RefitExecCmd)" />
<Message Text="Processed Refit Stubs" />
<ItemGroup>
<Compile Include="RefitStubs.$(TargetFramework).cs" />
</ItemGroup>
</Target>

</Project>
Loading