Refitter.SourceGenerator 0.7.0.20-preview

Additional Details

The generated Refit interface is not picked up by Refit so RestService.For<T>() fails to resolve the interface. See https://github.com/christianhelle/refitter/issues/100

This is a prerelease version of Refitter.SourceGenerator.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Refitter.SourceGenerator --version 0.7.0.20-preview
                    
NuGet\Install-Package Refitter.SourceGenerator -Version 0.7.0.20-preview
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Refitter.SourceGenerator" Version="0.7.0.20-preview">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Refitter.SourceGenerator" Version="0.7.0.20-preview" />
                    
Directory.Packages.props
<PackageReference Include="Refitter.SourceGenerator">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Refitter.SourceGenerator --version 0.7.0.20-preview
                    
#r "nuget: Refitter.SourceGenerator, 0.7.0.20-preview"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Refitter.SourceGenerator&version=0.7.0.20-preview&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Refitter.SourceGenerator&version=0.7.0.20-preview&prerelease
                    
Install as a Cake Tool

NuGet

Refitter Source Generator

A C# Source Generator that uses Refitter for generating a REST API Client using the Refit library. Refitter can generate the Refit interface from OpenAPI specifications

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

File format

{
  "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
  "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
  "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 .refitter file. This can also be a URL to a remote file that will be downloaded over HTTP/HTTPS
  • namespace - the namespace used in the generated code. If not specified, this defaults to GeneratedCode
  • naming.useOpenApiTitle - a boolean indicating whether the OpenApi title should be used. Default is true
  • naming.interfaceName - the name of the generated interface. The generated code will automatically prefix this with I so if this set to MyApiClient then the generated interface is called IMyApiClient. Default is ApiClient
  • generateContracts - a boolean indicating whether contracts should be generated. A use case for this is several API clients use the same contracts. Default is true
  • generateXmlDocCodeComments - a boolean indicating whether XML doc comments should be generated. Default is true
  • addAutoGeneratedHeader - a boolean indicating whether XML doc comments should be generated. Default is true
  • returnIApiResponse - a boolean indicating whether to return IApiResponse<T> objects. Default is false
  • generateOperationHeaders - a boolean indicating whether to use operation headers in the generated methods. Default is true
  • typeAccessibility - the generated type accessibility. Possible values are Public and Internal. Default is Public
  • useCancellationTokens - Use cancellation tokens in the generated methods. Default is false
  • useIsoDateFormat - Set to true to explicitly format date query string parameters in ISO 8601 standard date format using delimiters (for example: 2023-06-15). Default is false
  • 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
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.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.0 562 6/17/2025
1.6.0-preview.74 258 6/10/2025
1.5.6 496 6/7/2025
1.5.6-preview.73 53 5/31/2025
1.5.5 4,949 5/4/2025
1.5.5-preview.70 54 5/30/2025
1.5.5-preview.69 116 4/30/2025
1.5.4 361 4/26/2025
1.5.3 2,789 3/30/2025
1.5.3-preview.68 259 3/23/2025
1.5.3-preview.67 542 1/30/2025
1.5.2 4,775 1/29/2025
1.5.1 568 1/25/2025
1.5.1-preview.66 69 1/25/2025
1.5.0 399 1/19/2025
1.5.0-preview.65 114 12/8/2024
1.5.0-preview.64 71 12/7/2024
1.5.0-preview.63 77 12/7/2024
1.4.1 13,608 11/20/2024
1.4.1-preview.62 89 11/4/2024
1.4.0 6,710 10/14/2024
1.4.0-preview.61 75 10/7/2024
1.3.2 7,828 9/23/2024
1.3.2-preview.60 82 9/23/2024
1.3.1 1,097 9/20/2024
1.3.0 2,111 9/14/2024
1.2.1-preview.59 75 9/13/2024
1.2.1-preview.58 158 9/11/2024
1.2.1-preview.57 85 9/11/2024
1.2.1-preview.56 74 9/9/2024
1.2.1-preview.55 81 9/2/2024
1.2.1-preview.54 70 8/29/2024
1.2.0 3,239 8/12/2024
1.2.0-preview.53 52 8/4/2024
1.2.0-preview.52 69 7/29/2024
1.1.3 22,755 7/19/2024
1.1.3-preview.51 79 7/19/2024
1.1.2 24,876 7/17/2024 1.1.2 is deprecated because it has critical bugs.
1.1.2-preview.50 62 7/16/2024
1.1.2-preview.49 85 7/11/2024
1.1.1 187,458 7/6/2024
1.1.1-preview.48 71 7/4/2024
1.1.1-preview.47 78 7/1/2024
1.1.1-preview.46 82 6/28/2024
1.1.0.45-preview 126 6/25/2024
1.0.2 237,909 6/13/2024
1.0.1 48,531 6/7/2024
1.0.0 246,782 5/3/2024
0.9.9.44-preview 105 4/29/2024
0.9.9 10,875 3/7/2024
0.9.8 2,119 2/27/2024
0.9.7 73,455 2/7/2024
0.9.6 310 1/29/2024
0.9.5 33,740 1/15/2024
0.9.4.43-preview 189 1/15/2024
0.9.4 32,200 1/12/2024
0.9.3.42-preview 166 1/10/2024
0.9.2 20,250 1/10/2024
0.9.1 4,317 1/9/2024
0.9.0 11,383 1/9/2024
0.8.7.41-preview 177 1/3/2024
0.8.7.40-preview 251 12/20/2023
0.8.7 59,406 12/18/2023
0.8.6.39-preview 460 12/14/2023
0.8.6.38-preview 155 12/14/2023
0.8.6 10,489 12/11/2023
0.8.5 763 11/23/2023
0.8.4 835 11/7/2023
0.8.3 229 10/31/2023
0.8.2 2,468 10/9/2023
0.8.1 260 10/4/2023
0.8.0 9,084 9/23/2023
0.7.5 239 9/7/2023
0.7.4 227 9/6/2023
0.7.3.37-preview 280 8/25/2023
0.7.3.36-preview 184 8/25/2023
0.7.3.35-preview 241 8/21/2023
0.7.3.34-preview 219 8/15/2023
0.7.3.33-preview 392 8/12/2023
0.7.3 951 8/26/2023
0.7.2.32-preview 336 8/7/2023 0.7.2.32-preview is deprecated because it has critical bugs.
0.7.2 321 8/7/2023 0.7.2 is deprecated because it has critical bugs.
0.7.1.31-preview 346 8/2/2023 0.7.1.31-preview is deprecated because it has critical bugs.
0.7.1.30-preview 325 8/2/2023 0.7.1.30-preview is deprecated because it has critical bugs.
0.7.1.29-preview 214 8/1/2023 0.7.1.29-preview is deprecated because it has critical bugs.
0.7.1 284 8/3/2023 0.7.1 is deprecated because it has critical bugs.
0.7.0.28-preview 282 7/28/2023 0.7.0.28-preview is deprecated because it has critical bugs.
0.7.0.27-preview 296 7/28/2023 0.7.0.27-preview is deprecated because it has critical bugs.
0.7.0.26-preview 295 7/27/2023 0.7.0.26-preview is deprecated because it has critical bugs.
0.7.0.23-preview 308 7/27/2023 0.7.0.23-preview is deprecated because it has critical bugs.
0.7.0.22-preview 283 7/27/2023 0.7.0.22-preview is deprecated because it has critical bugs.
0.7.0.21-preview 252 7/27/2023 0.7.0.21-preview is deprecated because it has critical bugs.
0.7.0.20-preview 261 7/27/2023 0.7.0.20-preview is deprecated because it has critical bugs.
0.7.0 219 7/31/2023 0.7.0 is deprecated because it has critical bugs.
0.6.3.10 249 7/26/2023 0.6.3.10 is deprecated because it has critical bugs.
0.6.3.9 223 7/26/2023 0.6.3.9 is deprecated because it has critical bugs.
0.6.3.8 356 7/26/2023 0.6.3.8 is deprecated because it has critical bugs.
0.6.3.7-preview 280 7/26/2023 0.6.3.7-preview is deprecated because it has critical bugs.
0.6.3.6-preview 239 7/26/2023 0.6.3.6-preview is deprecated because it has critical bugs.
0.6.3.5-preview 297 7/26/2023 0.6.3.5-preview is deprecated because it has critical bugs.
0.6.3.4-preview 288 7/26/2023 0.6.3.4-preview is deprecated because it has critical bugs.