diff --git a/README.md b/README.md
index 4321edbb..be1bdc6e 100644
--- a/README.md
+++ b/README.md
@@ -119,7 +119,12 @@ OPTIONS:
See https://refitter.github.io for more information and https://www.apizr.net to get started with Apizr
--use-dynamic-querystring-parameters Enable wrapping multiple query parameters into a single complex one. Default is no wrapping.
See https://github.com/reactiveui/refit?tab=readme-ov-file#dynamic-querystring-parameters for more information
- --use-polymorphic-serialization Use System.Text.Json polymorphic serialization
+ --use-polymorphic-serialization Use System.Text.Json polymorphic serialization.
+ Replaces NSwag JsonInheritanceConverter attributes with System.Text.Json JsonPolymorphicAttributes.
+ To have the native support of inheritance (de)serialization and fallback to base types when
+ payloads with (yet) unknown types are offered by newer versions of an API
+ See https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/polymorphism for more information
+ --disposable Generate refit clients that implement IDisposable
```
To generate code from an OpenAPI specifications file, run the following:
@@ -210,7 +215,8 @@ The following is an example `.refitter` file
"operationNameGenerator": "Default", // Optional. May be one of Default, MultipleClientsFromOperationId, MultipleClientsFromPathSegments, MultipleClientsFromFirstTagAndOperationId, MultipleClientsFromFirstTagAndOperationName, MultipleClientsFromFirstTagAndPathSegments, SingleClientFromOperationId, SingleClientFromPathSegments
"immutableRecords": false,
"useDynamicQuerystringParameters": true, // Optional. Default=false
- "usePolymorphicSerialization", false, // Optional. Default=false
+ "usePolymorphicSerialization": true, // Optional. Default=false
+ "generateDisposableClients": true, // Optional. Default=false
"dependencyInjectionSettings": { // Optional
"baseUrl": "https://petstore3.swagger.io/api/v3", // Optional. Leave this blank to set the base address manually
"httpMessageHandlers": [ // Optional
diff --git a/docs/docfx_project/articles/cli-tool.md b/docs/docfx_project/articles/cli-tool.md
index bf8db786..8b667081 100644
--- a/docs/docfx_project/articles/cli-tool.md
+++ b/docs/docfx_project/articles/cli-tool.md
@@ -93,16 +93,19 @@ OPTIONS:
- SingleClientFromPathSegments
See https://refitter.github.io/api/Refitter.Core.OperationNameGeneratorTypes.html for more information
--immutable-records Generate contracts as immutable records instead of classes
- --use-apizr Set to true to use Apizr by:
+ --use-apizr Use Apizr by:
- Adding a final IApizrRequestOptions options parameter to all generated methods
- Providing cancellation tokens by Apizr request options instead of a dedicated parameter
- Using method overloads instead of optional parameters
See https://refitter.github.io for more information and https://www.apizr.net to get started with Apizr
- --use-dynamic-querystring-parameters Set to true to wrap multiple query parameters into a single complex one. Default is false (no wrapping).
- See https://github.com/reactiveui/refit?tab=readme-ov-file#dynamic-querystring-parameters for more information
- --use-polymorphic-serialization Replaces NSwag JsonInheritanceConverter attributes with System.Text.Json JsonPolymorphicAttributes. To have the native support of inheritance (de)serialization and fallback to base types when payloads with (yet) unknown types are offered by newer versions of an API.
- See https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/polymorphism for more information
-
+ --use-dynamic-querystring-parameters Enable wrapping multiple query parameters into a single complex one. Default is no wrapping.
+ See https://github.com/reactiveui/refit?tab=readme-ov-file#dynamic-querystring-parameters for more information
+ --use-polymorphic-serialization Use System.Text.Json polymorphic serialization.
+ Replaces NSwag JsonInheritanceConverter attributes with System.Text.Json JsonPolymorphicAttributes.
+ To have the native support of inheritance (de)serialization and fallback to base types when
+ payloads with (yet) unknown types are offered by newer versions of an API
+ See https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/polymorphism for more information
+ --disposable Generate refit clients that implement IDisposable
```
To generate code from an OpenAPI specifications file, run the following:
diff --git a/docs/docfx_project/articles/refitter-file-format.md b/docs/docfx_project/articles/refitter-file-format.md
index 3efc1cf6..caaa6954 100644
--- a/docs/docfx_project/articles/refitter-file-format.md
+++ b/docs/docfx_project/articles/refitter-file-format.md
@@ -61,7 +61,8 @@ The following is an example `.refitter` file
"operationNameGenerator": "Default", // Optional. May be one of Default, MultipleClientsFromOperationId, MultipleClientsFromPathSegments, MultipleClientsFromFirstTagAndOperationId, MultipleClientsFromFirstTagAndOperationName, MultipleClientsFromFirstTagAndPathSegments, SingleClientFromOperationId, SingleClientFromPathSegments
"immutableRecords": false,
"useDynamicQuerystringParameters": false, // Optional. Default=false
- "usePolymorphicSerialization": false, // Optional. Default=false
+ "usePolymorphicSerialization": true, // Optional. Default=false
+ "generateDisposableClients": true, // Optional. Default=false
"dependencyInjectionSettings": { // Optional
"baseUrl": "https://petstore3.swagger.io/api/v3", // Optional. Leave this blank to set the base address manually
"httpMessageHandlers": [ // Optional
diff --git a/docs/json-schema.json b/docs/json-schema.json
index 38a03ef6..1c2d275f 100644
--- a/docs/json-schema.json
+++ b/docs/json-schema.json
@@ -157,6 +157,14 @@
"type": "boolean",
"description": "Set to `true` to generate multiple files. Refit interface(s) are written to a file called `RefitInterfaces.cs`, Contracts are written to a file called `Contracts.cs`, and Dependency Injection is written to a file called `DependencyInjection.cs`"
},
+ "usePolymorphicSerialization": {
+ "type": "boolean",
+ "description": "Use System.Text.Json polymorphic serialization. Replaces NSwag JsonInheritanceConverter attributes with System.Text.Json JsonPolymorphicAttributes. To have the native support of inheritance (de)serialization and fallback to base types when payloads with (yet) unknown types are offered by newer versions of an API. See https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/polymorphism for more information"
+ },
+ "generateDisposableClients": {
+ "type": "boolean",
+ "description": "Set to `true` to generate disposable clients. Refit interfaces are generated as disposable clients."
+ },
"dependencyInjectionSettings": {
"type": "object",
"properties": {
diff --git a/src/Refitter.Core/RefitInterfaceGenerator.cs b/src/Refitter.Core/RefitInterfaceGenerator.cs
index 28357ec2..322e05e5 100644
--- a/src/Refitter.Core/RefitInterfaceGenerator.cs
+++ b/src/Refitter.Core/RefitInterfaceGenerator.cs
@@ -252,13 +252,13 @@ private string GenerateInterfaceDeclaration(out string interfaceName)
interfaceName = $"I{title.CapitalizeFirstCharacter()}";
var inheritance = settings.GenerateDisposableClients
- ? ": IDisposable"
+ ? " : IDisposable"
: null;
-
+
var modifier = settings.TypeAccessibility.ToString().ToLowerInvariant();
return $"""
{Separator}{GetGeneratedCodeAttribute()}
- {Separator}{modifier} partial interface {interfaceName} {inheritance}
+ {Separator}{modifier} partial interface {interfaceName}{inheritance}
""";
}
diff --git a/src/Refitter.Core/RefitInterfaceImports.cs b/src/Refitter.Core/RefitInterfaceImports.cs
index 9d44776a..7787f0f0 100644
--- a/src/Refitter.Core/RefitInterfaceImports.cs
+++ b/src/Refitter.Core/RefitInterfaceImports.cs
@@ -15,11 +15,6 @@ public static string[] GetImportedNamespaces(RefitGeneratorSettings settings)
{
var namespaces = new List(defaultNamespases);
- if(settings.GenerateDisposableClients)
- {
- namespaces.Add("System");
- }
-
if (settings.ApizrSettings?.WithRequestOptions == true)
{
namespaces.Add("Apizr.Configuring.Request");
@@ -44,7 +39,7 @@ public static string[] GetImportedNamespaces(RefitGeneratorSettings settings)
.Where(n => !string.IsNullOrWhiteSpace(n))
.Select(x => new Regex(x, RegexOptions.Compiled))
.ToList();
-
+
var excludedNamespaces = exclusionNamespacesRegexes.SelectMany(k => namespaces.Where(x => k.IsMatch(x)));
namespaces = namespaces.Except(excludedNamespaces).ToList();
}
@@ -65,4 +60,4 @@ public static string GenerateNamespaceImports(RefitGeneratorSettings settings) =
GetImportedNamespaces(settings)
.Select(ns => $"using {ns};")
.Aggregate((a, b) => $"{a}{Environment.NewLine}{b}");
-}
\ No newline at end of file
+}
diff --git a/src/Refitter.SourceGenerator/README.md b/src/Refitter.SourceGenerator/README.md
index e15a0dd4..1c21858f 100644
--- a/src/Refitter.SourceGenerator/README.md
+++ b/src/Refitter.SourceGenerator/README.md
@@ -66,7 +66,8 @@ The following is an example `.refitter` file
"^/store/.*"
],
"useDynamicQuerystringParameters": true, // Optional. Default=false
- "usePolymorphicSerialization": false, // Optional. Default=false
+ "usePolymorphicSerialization": true, // Optional. Default=false
+ "generateDisposableClients": true, // Optional. Default=false
"dependencyInjectionSettings": { // Optional
"baseUrl": "https://petstore3.swagger.io/api/v3", // Optional. Leave this blank to set the base address manually
"httpMessageHandlers": [ // Optional
diff --git a/src/Refitter.Tests/SwaggerPetstoreMultipleFileTests.cs b/src/Refitter.Tests/SwaggerPetstoreMultipleFileTests.cs
index cb22f7b1..fb087875 100644
--- a/src/Refitter.Tests/SwaggerPetstoreMultipleFileTests.cs
+++ b/src/Refitter.Tests/SwaggerPetstoreMultipleFileTests.cs
@@ -94,6 +94,28 @@ await GenerateCode(
});
}
+ [Theory]
+ [InlineData(SampleOpenSpecifications.SwaggerPetstoreJsonV3, "SwaggerPetstore.json")]
+#if !DEBUG
+ [InlineData(SampleOpenSpecifications.SwaggerPetstoreYamlV3, "SwaggerPetstore.yaml")]
+ [InlineData(SampleOpenSpecifications.SwaggerPetstoreJsonV2, "SwaggerPetstore.json")]
+ [InlineData(SampleOpenSpecifications.SwaggerPetstoreYamlV2, "SwaggerPetstore.yaml")]
+#endif
+ public async Task Can_Build_Generate_Code_With_IDisposable(SampleOpenSpecifications version, string filename)
+ {
+ await GenerateCode(
+ version,
+ filename,
+ new RefitGeneratorSettings { GenerateDisposableClients = true },
+ assert: generatorOutput =>
+ {
+ BuildHelper
+ .BuildCSharp(generatorOutput.Files.Select(code => code.Content).ToArray())
+ .Should()
+ .BeTrue();
+ });
+ }
+
private static async Task GenerateCode(
SampleOpenSpecifications version,
string filename,
diff --git a/src/Refitter.Tests/SwaggerPetstoreTests.cs b/src/Refitter.Tests/SwaggerPetstoreTests.cs
index 9828173e..83c1e4da 100644
--- a/src/Refitter.Tests/SwaggerPetstoreTests.cs
+++ b/src/Refitter.Tests/SwaggerPetstoreTests.cs
@@ -358,7 +358,7 @@ public async Task Can_Generate_Code_Dependency_Injection_Setup_Without_Polly(Sam
[InlineData(SampleOpenSpecifications.SwaggerPetstoreYamlV2, "SwaggerPetstore.yaml")]
public async Task Can_Generate_Code_Apizr_Setup(SampleOpenSpecifications version, string filename)
{
- var settings = new RefitGeneratorSettings
+ var settings = new RefitGeneratorSettings
{
DependencyInjectionSettings = new DependencyInjectionSettings
{
@@ -387,7 +387,7 @@ public async Task Can_Generate_Code_Apizr_Setup(SampleOpenSpecifications version
[InlineData(SampleOpenSpecifications.SwaggerPetstoreYamlV2, "SwaggerPetstore.yaml")]
public async Task Can_Generate_Code_Apizr_Setup_With_Polly(SampleOpenSpecifications version, string filename)
{
- var settings = new RefitGeneratorSettings
+ var settings = new RefitGeneratorSettings
{
DependencyInjectionSettings = new DependencyInjectionSettings
{
@@ -416,7 +416,7 @@ public async Task Can_Generate_Code_Apizr_Setup_With_Polly(SampleOpenSpecificati
[InlineData(SampleOpenSpecifications.SwaggerPetstoreYamlV2, "SwaggerPetstore.yaml")]
public async Task Can_Generate_Code_Apizr_Setup_Without_Polly(SampleOpenSpecifications version, string filename)
{
- var settings = new RefitGeneratorSettings
+ var settings = new RefitGeneratorSettings
{
DependencyInjectionSettings = new DependencyInjectionSettings
{
@@ -740,4 +740,34 @@ public async Task Can_Generate_Code_With_DynamicQuerystringParameters(SampleOpen
generateCode.Should().Contain("[Query] LoginUserQueryParams queryParams);")
.And.Contain("public class LoginUserQueryParams");
}
+
+ [Theory]
+ [InlineData(SampleOpenSpecifications.SwaggerPetstoreJsonV3, "SwaggerPetstore.json")]
+ [InlineData(SampleOpenSpecifications.SwaggerPetstoreYamlV3, "SwaggerPetstore.yaml")]
+ [InlineData(SampleOpenSpecifications.SwaggerPetstoreJsonV2, "SwaggerPetstore.json")]
+ [InlineData(SampleOpenSpecifications.SwaggerPetstoreYamlV2, "SwaggerPetstore.yaml")]
+ public async Task Can_Generate_Code_With_IDisposable(SampleOpenSpecifications version, string filename)
+ {
+ var settings = new RefitGeneratorSettings { GenerateDisposableClients = true };
+ var generateCode = await GenerateCode(version, filename, settings);
+ generateCode.Should().Contain("IDisposable");
+ }
+
+ [Theory]
+ [InlineData(SampleOpenSpecifications.SwaggerPetstoreJsonV3, "SwaggerPetstore.json")]
+#if !DEBUG
+ [InlineData(SampleOpenSpecifications.SwaggerPetstoreYamlV3, "SwaggerPetstore.yaml")]
+ [InlineData(SampleOpenSpecifications.SwaggerPetstoreJsonV2, "SwaggerPetstore.json")]
+ [InlineData(SampleOpenSpecifications.SwaggerPetstoreYamlV2, "SwaggerPetstore.yaml")]
+#endif
+ public async Task Can_Build_Generated_Code_With_IDisposable(SampleOpenSpecifications version, string filename)
+ {
+ var settings = new RefitGeneratorSettings();
+ settings.GenerateDisposableClients = true;
+ var generateCode = await GenerateCode(version, filename, settings);
+ BuildHelper
+ .BuildCSharp(generateCode)
+ .Should()
+ .BeTrue();
+ }
}
diff --git a/src/Refitter/GenerateCommand.cs b/src/Refitter/GenerateCommand.cs
index 3c3674db..05b462d1 100644
--- a/src/Refitter/GenerateCommand.cs
+++ b/src/Refitter/GenerateCommand.cs
@@ -133,6 +133,7 @@ private static RefitGeneratorSettings CreateRefitGeneratorSettings(Settings sett
ContractsOutputFolder = settings.ContractsOutputPath ?? settings.OutputPath,
ContractsNamespace = settings.ContractsNamespace,
UsePolymorphicSerialization = settings.UsePolymorphicSerialization,
+ GenerateDisposableClients = settings.GenerateDisposableClients,
};
}
diff --git a/src/Refitter/README.md b/src/Refitter/README.md
index d7c6d41f..cde83012 100644
--- a/src/Refitter/README.md
+++ b/src/Refitter/README.md
@@ -41,62 +41,74 @@ EXAMPLES:
refitter ./openapi.json --no-deprecated-operations
refitter ./openapi.json --operation-name-template '{operationName}Async'
refitter ./openapi.json --optional-nullable-parameters
- refitter ./openapi.json --use-apizr
- refitter ./openapi.json --use-dynamic-querystring-parameters
+ refitter ./openapi.json --use-polymorphic-serialization
ARGUMENTS:
[URL or input file] URL or file path to OpenAPI Specification file
OPTIONS:
- DEFAULT
- -h, --help Prints help information
- -v, --version Prints version information
- -s, --settings-file Path to .refitter settings file. Specifying this will ignore all other settings (except for --output)
- -n, --namespace GeneratedCode Default namespace to use for generated types
- -o, --output Output.cs Path to Output file
- --no-auto-generated-header Don't add header to output file
- --no-accept-headers Don't add header to output file
- --interface-only Don't generate contract types
- --use-api-response Return Task> instead of Task
- --use-observable-response Return IObservable instead of Task
- --internal Set the accessibility of the generated types to 'internal'
- --cancellation-tokens Use cancellation tokens
- --no-operation-headers Don't generate operation headers
- --no-logging Don't log errors or collect telemetry
- --additional-namespace Add additional namespace to generated types
- --exclude-namespace Exclude namespace on generated types
- --use-iso-date-format Explicitly format date query string parameters in ISO 8601 standard date format using delimiters (2023-06-15)
- --multiple-interfaces Generate a Refit interface for each endpoint. May be one of ByEndpoint, ByTag
- --match-path Only include Paths that match the provided regular expression. May be set multiple times
- --tag Only include Endpoints that contain this tag. May be set multiple times and result in OR'ed evaluation
- --skip-validation Skip validation of the OpenAPI specification
- --no-deprecated-operations Don't generate deprecated operations
- --operation-name-template Generate operation names using pattern. When using --multiple-interfaces ByEndpoint, this is name of the Execute() method in the interface
- --optional-nullable-parameters Generate nullable parameters as optional parameters
- --trim-unused-schema Removes unreferenced components schema to keep the generated output to a minimum
- --keep-schema Force to keep matching schema, uses regular expressions. Use together with "--trim-unused-schema". Can be set multiple times
- --no-banner Don't show donation banner
- --skip-default-additional-properties Set to true to skip default additional properties
- --operation-name-generator Default The NSwag IOperationNameGenerator implementation to use.
- May be one of:
- - Default
- - MultipleClientsFromOperationId
- - MultipleClientsFromPathSegments
- - MultipleClientsFromFirstTagAndOperationId
- - MultipleClientsFromFirstTagAndOperationName
- - MultipleClientsFromFirstTagAndPathSegments
- - SingleClientFromOperationId
- - SingleClientFromPathSegments
- See https://refitter.github.io/api/Refitter.Core.OperationNameGeneratorTypes.html for more information
- --immutable-records Generate contracts as immutable records instead of classes
- --use-apizr Set to true to use Apizr by:
- - Adding a final IApizrRequestOptions options parameter to all generated methods
- - Providing cancellation tokens by Apizr request options instead of a dedicated parameter
- - Using method overloads instead of optional parameters
- See https://refitter.github.io for more information and https://www.apizr.net to get started with Apizr
- --use-dynamic-querystring-parameters Wrap multiple query parameters into a single complex one.
- See https://github.com/reactiveui/refit?tab=readme-ov-file#dynamic-querystring-parameters for more information.
- --use-polymorphic-serialization Use System.Text.Json polymorphic serialization
+ DEFAULT
+ -h, --help Prints help information
+ -v, --version Prints version information
+ -s, --settings-file Path to .refitter settings file. Specifying this will ignore all other settings (except for --output)
+ -n, --namespace GeneratedCode Default namespace to use for generated types
+ --contracts-namespace Default namespace to use for generated contracts
+ -o, --output Output.cs Path to Output file or folder (if multiple files are generated)
+ --contracts-output Output path for generated contracts. Enabling this automatically enables generating multiple files
+ --no-auto-generated-header Don't add header to output file
+ --no-accept-headers Don't add header to output file
+ --interface-only Don't generate contract types
+ --contract-only Don't generate clients
+ --use-api-response Return Task> instead of Task
+ --use-observable-response Return IObservable instead of Task
+ --internal Set the accessibility of the generated types to 'internal'
+ --cancellation-tokens Use cancellation tokens
+ --no-operation-headers Don't generate operation headers
+ --no-logging Don't log errors or collect telemetry
+ --additional-namespace Add additional namespace to generated types
+ --exclude-namespace Exclude namespace on generated types
+ --use-iso-date-format Explicitly format date query string parameters in ISO 8601 standard date format using delimiters (2023-06-15)
+ --multiple-interfaces Generate a Refit interface for each endpoint. May be one of ByEndpoint, ByTag
+ --multiple-files Generate multiple files instead of a single large file.
+ The output files can be the following:
+ - RefitInterfaces.cs
+ - DependencyInjection.cs
+ - Contracts.cs
+ --match-path Only include Paths that match the provided regular expression. May be set multiple times
+ --tag Only include Endpoints that contain this tag. May be set multiple times and result in OR'ed evaluation
+ --skip-validation Skip validation of the OpenAPI specification
+ --no-deprecated-operations Don't generate deprecated operations
+ --operation-name-template Generate operation names using pattern. When using --multiple-interfaces ByEndpoint, this is name of the Execute() method in the interface
+ --optional-nullable-parameters Generate nullable parameters as optional parameters
+ --trim-unused-schema Removes unreferenced components schema to keep the generated output to a minimum
+ --keep-schema Force to keep matching schema, uses regular expressions. Use together with "--trim-unused-schema". Can be set multiple times
+ --no-banner Don't show donation banner
+ --skip-default-additional-properties Set to true to skip default additional properties
+ --operation-name-generator Default The NSwag IOperationNameGenerator implementation to use.
+ May be one of:
+ - Default
+ - MultipleClientsFromOperationId
+ - MultipleClientsFromPathSegments
+ - MultipleClientsFromFirstTagAndOperationId
+ - MultipleClientsFromFirstTagAndOperationName
+ - MultipleClientsFromFirstTagAndPathSegments
+ - SingleClientFromOperationId
+ - SingleClientFromPathSegments
+ See https://refitter.github.io/api/Refitter.Core.OperationNameGeneratorTypes.html for more information
+ --immutable-records Generate contracts as immutable records instead of classes
+ --use-apizr Use Apizr by:
+ - Adding a final IApizrRequestOptions options parameter to all generated methods
+ - Providing cancellation tokens by Apizr request options instead of a dedicated parameter
+ - Using method overloads instead of optional parameters
+ See https://refitter.github.io for more information and https://www.apizr.net to get started with Apizr
+ --use-dynamic-querystring-parameters Enable wrapping multiple query parameters into a single complex one. Default is no wrapping.
+ See https://github.com/reactiveui/refit?tab=readme-ov-file#dynamic-querystring-parameters for more information
+ --use-polymorphic-serialization Use System.Text.Json polymorphic serialization.
+ Replaces NSwag JsonInheritanceConverter attributes with System.Text.Json JsonPolymorphicAttributes.
+ To have the native support of inheritance (de)serialization and fallback to base types when
+ payloads with (yet) unknown types are offered by newer versions of an API
+ See https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/polymorphism for more information
+ --disposable Generate refit clients that implement IDisposable
```
### .Refitter File format
@@ -157,7 +169,8 @@ The following is an example `.refitter` file
"operationNameGenerator": "Default", // Optional. May be one of Default, MultipleClientsFromOperationId, MultipleClientsFromPathSegments, MultipleClientsFromFirstTagAndOperationId, MultipleClientsFromFirstTagAndOperationName, MultipleClientsFromFirstTagAndPathSegments, SingleClientFromOperationId, SingleClientFromPathSegments
"immutableRecords": false,
"useDynamicQuerystringParameters": true, // Optional. Default=false
- "usePolymorphicSerialization" true, // Optional. Default=false
+ "usePolymorphicSerialization": true, // Optional. Default=false
+ "generateDisposableClients": true, // Optional. Default=false
"dependencyInjectionSettings": { // Optional
"baseUrl": "https://petstore3.swagger.io/api/v3", // Optional. Leave this blank to set the base address manually
"httpMessageHandlers": [ // Optional
diff --git a/src/Refitter/Settings.cs b/src/Refitter/Settings.cs
index f3bdcc56..14b0a4dd 100644
--- a/src/Refitter/Settings.cs
+++ b/src/Refitter/Settings.cs
@@ -109,7 +109,7 @@ public sealed class Settings : CommandSettings
public Core.MultipleInterfaces MultipleInterfaces { get; set; } = Core.MultipleInterfaces.Unset;
[Description("""
- Generate multiple files instead of a single large file.
+ Generate multiple files instead of a single large file.
The output files can be the following:
- RefitInterfaces.cs
- DependencyInjection.cs
@@ -169,8 +169,8 @@ Generate multiple files instead of a single large file.
public bool SkipDefaultAdditionalProperties { get; set; }
[Description("""
- The NSwag IOperationNameGenerator implementation to use.
- May be one of:
+ The NSwag IOperationNameGenerator implementation to use.
+ May be one of:
- Default
- MultipleClientsFromOperationId
- MultipleClientsFromPathSegments
@@ -219,4 +219,9 @@ payloads with (yet) unknown types are offered by newer versions of an API
[CommandOption("--use-polymorphic-serialization")]
[DefaultValue(false)]
public bool UsePolymorphicSerialization { get; set; }
+
+ [Description("Generate refit clients that implement IDisposable")]
+ [CommandOption("--disposable")]
+ [DefaultValue(false)]
+ public bool GenerateDisposableClients { get; set; }
}
diff --git a/test/smoke-tests.ps1 b/test/smoke-tests.ps1
index e7e6c981..3da7d02f 100644
--- a/test/smoke-tests.ps1
+++ b/test/smoke-tests.ps1
@@ -153,6 +153,7 @@ function RunTests {
$namespace = $_.Replace("-", "")
$namespace = $namespace.Substring(0, 1).ToUpperInvariant() + $namespace.Substring(1, $namespace.Length - 1)
+ GenerateAndBuild -format $format -namespace "$namespace.Disposable" -outputPath "Disposable$outputPath" -args "--disposable" -buildFromSource $buildFromSource -netCore
GenerateAndBuild -format $format -namespace "$namespace.MultipleFiles" -args "--multiple-files" -buildFromSource $buildFromSource
GenerateAndBuild -format $format -namespace "$namespace.SeparateContractsFile" -args "--contracts-output GeneratedCode/Contracts --contracts-namespace $namespace.SeparateContractsFile.Contracts" -buildFromSource $buildFromSource
GenerateAndBuild -format $format -namespace "$namespace.Cancellation" -outputPath "WithCancellation$outputPath" "--cancellation-tokens" -buildFromSource $buildFromSource