Refitter.SourceGenerator
0.7.0
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
See the version list below for details.
dotnet add package Refitter.SourceGenerator --version 0.7.0
NuGet\Install-Package Refitter.SourceGenerator -Version 0.7.0
<PackageReference Include="Refitter.SourceGenerator" Version="0.7.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Refitter.SourceGenerator --version 0.7.0
#r "nuget: Refitter.SourceGenerator, 0.7.0"
// Install Refitter.SourceGenerator as a Cake Addin #addin nuget:?package=Refitter.SourceGenerator&version=0.7.0 // Install Refitter.SourceGenerator as a Cake Tool #tool nuget:?package=Refitter.SourceGenerator&version=0.7.0
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/HTTPSnamespace
- the namespace used in the generated code. If not specified, this defaults toGeneratedCode
naming.useOpenApiTitle
- a boolean indicating whether the OpenApi title should be used. Default istrue
naming.interfaceName
- the name of the generated interface. The generated code will automatically prefix this withI
so if this set toMyApiClient
then the generated interface is calledIMyApiClient
. Default isApiClient
generateContracts
- a boolean indicating whether contracts should be generated. A use case for this is several API clients use the same contracts. Default istrue
generateXmlDocCodeComments
- a boolean indicating whether XML doc comments should be generated. Default istrue
addAutoGeneratedHeader
- a boolean indicating whether XML doc comments should be generated. Default istrue
returnIApiResponse
- a boolean indicating whether to returnIApiResponse<T>
objects. Default isfalse
generateOperationHeaders
- a boolean indicating whether to use operation headers in the generated methods. Default istrue
typeAccessibility
- the generated type accessibility. Possible values arePublic
andInternal
. Default isPublic
useCancellationTokens
- Use cancellation tokens in the generated methods. Default isfalse
useIsoDateFormat
- Set totrue
to explicitly format date query string parameters in ISO 8601 standard date format using delimiters (for example: 2023-06-15). Default isfalse
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 (1)
Showing the top 1 popular GitHub repositories that depend on Refitter.SourceGenerator:
Repository | Stars |
---|---|
christianhelle/refitter
A tool for generating Refit interfaces and contracts from OpenAPI specifications
|
Version | Downloads | Last updated | |
---|---|---|---|
1.4.1-preview.62 | 30 | 11/4/2024 | |
1.4.0 | 2,039 | 10/14/2024 | |
1.4.0-preview.61 | 36 | 10/7/2024 | |
1.3.2 | 1,196 | 9/23/2024 | |
1.3.2-preview.60 | 42 | 9/23/2024 | |
1.3.1 | 516 | 9/20/2024 | |
1.3.0 | 551 | 9/14/2024 | |
1.2.1-preview.59 | 50 | 9/13/2024 | |
1.2.1-preview.58 | 123 | 9/11/2024 | |
1.2.1-preview.57 | 56 | 9/11/2024 | |
1.2.1-preview.56 | 49 | 9/9/2024 | |
1.2.1-preview.55 | 46 | 9/2/2024 | |
1.2.1-preview.54 | 42 | 8/29/2024 | |
1.2.0 | 2,529 | 8/12/2024 | |
1.2.0-preview.53 | 32 | 8/4/2024 | |
1.2.0-preview.52 | 45 | 7/29/2024 | |
1.1.3 | 19,296 | 7/19/2024 | |
1.1.3-preview.51 | 47 | 7/19/2024 | |
1.1.2 | 24,829 | 7/17/2024 | |
1.1.2-preview.50 | 41 | 7/16/2024 | |
1.1.2-preview.49 | 56 | 7/11/2024 | |
1.1.1 | 187,254 | 7/6/2024 | |
1.1.1-preview.48 | 46 | 7/4/2024 | |
1.1.1-preview.47 | 53 | 7/1/2024 | |
1.1.1-preview.46 | 56 | 6/28/2024 | |
1.1.0.45-preview | 92 | 6/25/2024 | |
1.0.2 | 237,786 | 6/13/2024 | |
1.0.1 | 48,469 | 6/7/2024 | |
1.0.0 | 246,630 | 5/3/2024 | |
0.9.9.44-preview | 77 | 4/29/2024 | |
0.9.9 | 10,192 | 3/7/2024 | |
0.9.8 | 2,084 | 2/27/2024 | |
0.9.7 | 73,326 | 2/7/2024 | |
0.9.6 | 280 | 1/29/2024 | |
0.9.5 | 33,703 | 1/15/2024 | |
0.9.4.43-preview | 154 | 1/15/2024 | |
0.9.4 | 32,164 | 1/12/2024 | |
0.9.3.42-preview | 146 | 1/10/2024 | |
0.9.2 | 20,208 | 1/10/2024 | |
0.9.1 | 4,091 | 1/9/2024 | |
0.9.0 | 7,984 | 1/9/2024 | |
0.8.7.41-preview | 157 | 1/3/2024 | |
0.8.7.40-preview | 234 | 12/20/2023 | |
0.8.7 | 59,366 | 12/18/2023 | |
0.8.6.39-preview | 440 | 12/14/2023 | |
0.8.6.38-preview | 130 | 12/14/2023 | |
0.8.6 | 10,406 | 12/11/2023 | |
0.8.5 | 623 | 11/23/2023 | |
0.8.4 | 814 | 11/7/2023 | |
0.8.3 | 209 | 10/31/2023 | |
0.8.2 | 2,412 | 10/9/2023 | |
0.8.1 | 225 | 10/4/2023 | |
0.8.0 | 6,991 | 9/23/2023 | |
0.7.5 | 206 | 9/7/2023 | |
0.7.4 | 188 | 9/6/2023 | |
0.7.3.37-preview | 251 | 8/25/2023 | |
0.7.3.36-preview | 158 | 8/25/2023 | |
0.7.3.35-preview | 214 | 8/21/2023 | |
0.7.3.34-preview | 191 | 8/15/2023 | |
0.7.3.33-preview | 330 | 8/12/2023 | |
0.7.3 | 882 | 8/26/2023 | |
0.7.2.32-preview | 289 | 8/7/2023 | |
0.7.2 | 266 | 8/7/2023 | |
0.7.1.31-preview | 279 | 8/2/2023 | |
0.7.1.30-preview | 275 | 8/2/2023 | |
0.7.1.29-preview | 173 | 8/1/2023 | |
0.7.1 | 240 | 8/3/2023 | |
0.7.0.28-preview | 239 | 7/28/2023 | |
0.7.0.27-preview | 246 | 7/28/2023 | |
0.7.0.26-preview | 255 | 7/27/2023 | |
0.7.0.23-preview | 265 | 7/27/2023 | |
0.7.0.22-preview | 241 | 7/27/2023 | |
0.7.0.21-preview | 207 | 7/27/2023 | |
0.7.0.20-preview | 217 | 7/27/2023 | |
0.7.0 | 174 | 7/31/2023 | |
0.6.3.10 | 199 | 7/26/2023 | |
0.6.3.9 | 177 | 7/26/2023 | |
0.6.3.8 | 224 | 7/26/2023 | |
0.6.3.7-preview | 235 | 7/26/2023 | |
0.6.3.6-preview | 202 | 7/26/2023 | |
0.6.3.5-preview | 252 | 7/26/2023 | |
0.6.3.4-preview | 248 | 7/26/2023 |