Refitter.SourceGenerator
0.7.3.37-preview
See the version list below for details.
dotnet add package Refitter.SourceGenerator --version 0.7.3.37-preview
NuGet\Install-Package Refitter.SourceGenerator -Version 0.7.3.37-preview
<PackageReference Include="Refitter.SourceGenerator" Version="0.7.3.37-preview"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Refitter.SourceGenerator" Version="0.7.3.37-preview" />
<PackageReference Include="Refitter.SourceGenerator"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Refitter.SourceGenerator --version 0.7.3.37-preview
#r "nuget: Refitter.SourceGenerator, 0.7.3.37-preview"
#:package Refitter.SourceGenerator@0.7.3.37-preview
#addin nuget:?package=Refitter.SourceGenerator&version=0.7.3.37-preview&prerelease
#tool nuget:?package=Refitter.SourceGenerator&version=0.7.3.37-preview&prerelease
Source Generator
Refitter is available as a C# Source Generator that uses the Refitter.Core library for generating a REST API Client using the Refit library. Refitter can generate the Refit interface from OpenAPI specifications
The Refitter source generator is a bit untraditional in a sense that it creates a folder called Generated in the same location as the .refitter file and generates files to disk under the Generated folder. The source generator output should be included in the project and committed to source control. This is done because there is no other way to trigger the Refit source generator to pickup the Refitter generated code
(Translation: I couldn't for the life of me figure how to get that to work, sorry)
Installation
The source generator is distributed as a NuGet package and should be installed to the project that will contain the generated code
dotnet add package Refitter.SourceGenerator
Usage
This source generator generates code based on any .refitter file included to the project as AdditionalFiles.
The generator can automatically detect all .refitter files inside the project that referenced the Refitter.SourceGenerator package and there is no need to include them manually as AdditionalFiles
.Refitter File format
The following is an example .refitter file
{
"openApiPath": "/path/to/your/openAPI", // Required
"namespace": "Org.System.Service.Api.GeneratedCode", // Optional. Default=GeneratedCode
"naming": {
"useOpenApiTitle": false, // Optional. Default=true
"interfaceName": "MyApiClient" // Optional. Default=ApiClient
},
"generateContracts": true, // Optional. Default=true
"generateXmlDocCodeComments": true, // Optional. Default=true
"addAutoGeneratedHeader": true, // Optional. Default=true
"addAcceptHeaders": true, // Optional. Default=true
"returnIApiResponse": false, // Optional. Default=false
"generateOperationHeaders": true, // Optional. Default=true
"typeAccessibility": "Public", // Optional. Values=Public|Internal. Default=Public
"useCancellationTokens": false, // Optional. Default=false
"useIsoDateFormat": false, // Optional. Default=false
"multipleInterfaces": "ByEndpoint", // Optional. May be one of "ByEndpoint" or "ByTag"
"additionalNamespaces": [ // Optional
"Namespace1",
"Namespace2"
]
}
openApiPath- points to the OpenAPI Specifications file. This can be the path to a file stored on disk, relative to the.refitterfile. This can also be a URL to a remote file that will be downloaded over HTTP/HTTPSnamespace- the namespace used in the generated code. If not specified, this defaults toGeneratedCodenaming.useOpenApiTitle- a boolean indicating whether the OpenApi title should be used. Default istruenaming.interfaceName- the name of the generated interface. The generated code will automatically prefix this withIso if this set toMyApiClientthen the generated interface is calledIMyApiClient. Default isApiClientgenerateContracts- a boolean indicating whether contracts should be generated. A use case for this is several API clients use the same contracts. Default istruegenerateXmlDocCodeComments- a boolean indicating whether XML doc comments should be generated. Default istrueaddAutoGeneratedHeader- a boolean indicating whether XML doc comments should be generated. Default istrueaddAcceptHeaders- a boolean indicating whether to add accept headers [Headers("Accept: application/json")]. Default istruereturnIApiResponse- a boolean indicating whether to returnIApiResponse<T>objects. Default isfalsegenerateOperationHeaders- a boolean indicating whether to use operation headers in the generated methods. Default istruetypeAccessibility- the generated type accessibility. Possible values arePublicandInternal. Default isPublicuseCancellationTokens- Use cancellation tokens in the generated methods. Default isfalseuseIsoDateFormat- Set totrueto explicitly format date query string parameters in ISO 8601 standard date format using delimiters (for example: 2023-06-15). Default isfalsemultipleInterfaces- Set toByEndpointto generate an interface for each endpoint, orByTagto group Endpoints by their Tag (like SwaggerUI groups them).additionalNamespaces- A collection of additional namespaces to include in the generated file. A use case for this is when you want to reuse contracts from a different namespace than the generated code. Default is empty
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Refit (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.6.5 | 988 | 10/6/2025 | |
| 1.6.5-preview.85 | 113 | 10/6/2025 | |
| 1.6.5-preview.84 | 117 | 10/6/2025 | |
| 1.6.5-preview.83 | 113 | 10/6/2025 | |
| 1.6.5-preview.81 | 113 | 10/6/2025 | |
| 1.6.4 | 1,608 | 9/23/2025 | |
| 1.6.4-preview.80 | 120 | 9/20/2025 | |
| 1.6.3 | 1,290 | 9/18/2025 | |
| 1.6.3-preview.79 | 248 | 9/17/2025 | |
| 1.6.3-preview.78 | 105 | 9/13/2025 | |
| 1.6.3-preview.77 | 125 | 9/11/2025 | |
| 1.6.2 | 3,463 | 8/18/2025 | |
| 1.6.2-preview.76 | 128 | 8/13/2025 | |
| 1.6.1 | 2,139 | 7/8/2025 | |
| 1.6.1-preview.75 | 128 | 7/8/2025 | |
| 1.6.0 | 5,145 | 6/17/2025 | |
| 1.6.0-preview.74 | 289 | 6/10/2025 | |
| 1.5.6 | 1,059 | 6/7/2025 | |
| 1.5.6-preview.73 | 85 | 5/31/2025 | |
| 1.5.5 | 10,706 | 5/4/2025 | |
| 1.5.5-preview.70 | 65 | 5/30/2025 | |
| 1.5.5-preview.69 | 130 | 4/30/2025 | |
| 1.5.4 | 431 | 4/26/2025 | |
| 1.5.3 | 4,580 | 3/30/2025 | |
| 1.5.3-preview.68 | 282 | 3/23/2025 | |
| 1.5.3-preview.67 | 2,979 | 1/30/2025 | |
| 1.5.2 | 5,063 | 1/29/2025 | |
| 1.5.1 | 679 | 1/25/2025 | |
| 1.5.1-preview.66 | 80 | 1/25/2025 | |
| 1.5.0 | 450 | 1/19/2025 | |
| 1.5.0-preview.65 | 152 | 12/8/2024 | |
| 1.5.0-preview.64 | 94 | 12/7/2024 | |
| 1.5.0-preview.63 | 110 | 12/7/2024 | |
| 1.4.1 | 20,374 | 11/20/2024 | |
| 1.4.1-preview.62 | 113 | 11/4/2024 | |
| 1.4.0 | 7,641 | 10/14/2024 | |
| 1.4.0-preview.61 | 106 | 10/7/2024 | |
| 1.3.2 | 10,923 | 9/23/2024 | |
| 1.3.2-preview.60 | 96 | 9/23/2024 | |
| 1.3.1 | 1,184 | 9/20/2024 | |
| 1.3.0 | 2,194 | 9/14/2024 | |
| 1.2.1-preview.59 | 104 | 9/13/2024 | |
| 1.2.1-preview.58 | 168 | 9/11/2024 | |
| 1.2.1-preview.57 | 112 | 9/11/2024 | |
| 1.2.1-preview.56 | 85 | 9/9/2024 | |
| 1.2.1-preview.55 | 112 | 9/2/2024 | |
| 1.2.1-preview.54 | 98 | 8/29/2024 | |
| 1.2.0 | 3,473 | 8/12/2024 | |
| 1.2.0-preview.53 | 62 | 8/4/2024 | |
| 1.2.0-preview.52 | 82 | 7/29/2024 | |
| 1.1.3 | 23,135 | 7/19/2024 | |
| 1.1.3-preview.51 | 91 | 7/19/2024 | |
| 1.1.2 | 24,924 | 7/17/2024 | |
| 1.1.2-preview.50 | 75 | 7/16/2024 | |
| 1.1.2-preview.49 | 116 | 7/11/2024 | |
| 1.1.1 | 187,570 | 7/6/2024 | |
| 1.1.1-preview.48 | 83 | 7/4/2024 | |
| 1.1.1-preview.47 | 92 | 7/1/2024 | |
| 1.1.1-preview.46 | 105 | 6/28/2024 | |
| 1.1.0.45-preview | 157 | 6/25/2024 | |
| 1.0.2 | 237,967 | 6/13/2024 | |
| 1.0.1 | 48,583 | 6/7/2024 | |
| 1.0.0 | 246,845 | 5/3/2024 | |
| 0.9.9.44-preview | 153 | 4/29/2024 | |
| 0.9.9 | 11,001 | 3/7/2024 | |
| 0.9.8 | 2,159 | 2/27/2024 | |
| 0.9.7 | 73,491 | 2/7/2024 | |
| 0.9.6 | 355 | 1/29/2024 | |
| 0.9.5 | 33,768 | 1/15/2024 | |
| 0.9.4.43-preview | 225 | 1/15/2024 | |
| 0.9.4 | 32,228 | 1/12/2024 | |
| 0.9.3.42-preview | 195 | 1/10/2024 | |
| 0.9.2 | 20,305 | 1/10/2024 | |
| 0.9.1 | 4,371 | 1/9/2024 | |
| 0.9.0 | 11,436 | 1/9/2024 | |
| 0.8.7.41-preview | 207 | 1/3/2024 | |
| 0.8.7.40-preview | 281 | 12/20/2023 | |
| 0.8.7 | 59,439 | 12/18/2023 | |
| 0.8.6.39-preview | 489 | 12/14/2023 | |
| 0.8.6.38-preview | 175 | 12/14/2023 | |
| 0.8.6 | 10,530 | 12/11/2023 | |
| 0.8.5 | 783 | 11/23/2023 | |
| 0.8.4 | 871 | 11/7/2023 | |
| 0.8.3 | 249 | 10/31/2023 | |
| 0.8.2 | 2,494 | 10/9/2023 | |
| 0.8.1 | 304 | 10/4/2023 | |
| 0.8.0 | 10,172 | 9/23/2023 | |
| 0.7.5 | 280 | 9/7/2023 | |
| 0.7.4 | 274 | 9/6/2023 | |
| 0.7.3.37-preview | 326 | 8/25/2023 | |
| 0.7.3.36-preview | 218 | 8/25/2023 | |
| 0.7.3.35-preview | 296 | 8/21/2023 | |
| 0.7.3.34-preview | 264 | 8/15/2023 | |
| 0.7.3.33-preview | 433 | 8/12/2023 | |
| 0.7.3 | 998 | 8/26/2023 | |
| 0.7.2.32-preview | 416 | 8/7/2023 | |
| 0.7.2 | 406 | 8/7/2023 | |
| 0.7.1.31-preview | 416 | 8/2/2023 | |
| 0.7.1.30-preview | 383 | 8/2/2023 | |
| 0.7.1.29-preview | 275 | 8/1/2023 | |
| 0.7.1 | 361 | 8/3/2023 | |
| 0.7.0.28-preview | 343 | 7/28/2023 | |
| 0.7.0.27-preview | 378 | 7/28/2023 | |
| 0.7.0.26-preview | 356 | 7/27/2023 | |
| 0.7.0.23-preview | 378 | 7/27/2023 | |
| 0.7.0.22-preview | 353 | 7/27/2023 | |
| 0.7.0.21-preview | 321 | 7/27/2023 | |
| 0.7.0.20-preview | 322 | 7/27/2023 | |
| 0.7.0 | 292 | 7/31/2023 | |
| 0.6.3.10 | 332 | 7/26/2023 | |
| 0.6.3.9 | 297 | 7/26/2023 | |
| 0.6.3.8 | 499 | 7/26/2023 | |
| 0.6.3.7-preview | 352 | 7/26/2023 | |
| 0.6.3.6-preview | 306 | 7/26/2023 | |
| 0.6.3.5-preview | 369 | 7/26/2023 | |
| 0.6.3.4-preview | 354 | 7/26/2023 |