diff --git a/src/Refitter.Core/ApizrRegistrationGenerator.cs b/src/Refitter.Core/ApizrRegistrationGenerator.cs
index a46933206..21872a3f5 100644
--- a/src/Refitter.Core/ApizrRegistrationGenerator.cs
+++ b/src/Refitter.Core/ApizrRegistrationGenerator.cs
@@ -1,4 +1,4 @@
-using System.Globalization;
+using System.Globalization;
using System.Text;
using Refitter.Core.Settings;
@@ -235,20 +235,7 @@ public static string Generate(
""");
}
- if (settings.ApizrSettings.WithOptionalMediation && isDependencyInjectionExtension)
- {
- apizrPackages.Add(ApizrPackages.Apizr_Integrations_Optional);
- usingsCodeBuilder.AppendLine(
- $$"""
- using MediatR;
- """);
- optionsCodeBuilder.AppendLine();
- optionsCodeBuilder.Append(
- $$"""
- .WithOptionalMediation()
- """);
- }
- else if (settings.ApizrSettings.WithMediation && isDependencyInjectionExtension)
+ if (settings.ApizrSettings.WithMediation && isDependencyInjectionExtension)
{
apizrPackages.Add(ApizrPackages.Apizr_Integrations_MediatR);
usingsCodeBuilder.AppendLine(
@@ -266,16 +253,7 @@ public static string Generate(
{
if (isDependencyInjectionExtension)
{
- if (settings.ApizrSettings.WithOptionalMediation)
- {
- apizrPackages.Add(ApizrPackages.Apizr_Integrations_FileTransfer_Optional);
- optionsCodeBuilder.AppendLine();
- optionsCodeBuilder.Append(
- $$"""
- .WithFileTransferOptionalMediation()
- """);
- }
- else if (settings.ApizrSettings.WithMediation)
+ if (settings.ApizrSettings.WithMediation)
{
apizrPackages.Add(ApizrPackages.Apizr_Integrations_FileTransfer_MediatR);
optionsCodeBuilder.AppendLine();
@@ -310,8 +288,7 @@ public static string Generate(
var packages = apizrPackages.OrderByDescending(p => p).ToList();
if (packages.Count > 0)
{
- if (!isDependencyInjectionExtension && (settings.ApizrSettings.WithOptionalMediation ||
- settings.ApizrSettings.WithMediation ||
+ if (!isDependencyInjectionExtension && (settings.ApizrSettings.WithMediation ||
settings.ApizrSettings.WithCacheProvider == CacheProviderType.InMemory ||
settings.ApizrSettings.WithCacheProvider == CacheProviderType.DistributedAsString ||
settings.ApizrSettings.WithCacheProvider == CacheProviderType.DistributedAsByteArray))
@@ -660,4 +637,4 @@ public static partial class ApizrRegistration
code.AppendLine();
return code.ToString();
}
-}
\ No newline at end of file
+}
diff --git a/src/Refitter.Core/Settings/ApizrPackages.cs b/src/Refitter.Core/Settings/ApizrPackages.cs
index c166d4c3c..6efabe5cb 100644
--- a/src/Refitter.Core/Settings/ApizrPackages.cs
+++ b/src/Refitter.Core/Settings/ApizrPackages.cs
@@ -1,4 +1,4 @@
-using System.ComponentModel;
+using System.ComponentModel;
namespace Refitter.Core.Settings
{
@@ -38,12 +38,6 @@ public enum ApizrPackages
Apizr_Integrations_MediatR = 1024 | Apizr_Extensions_Microsoft_DependencyInjection,
[Description("dotnet add package Apizr.Integrations.FileTransfer.MediatR, then register MediatR")]
- Apizr_Integrations_FileTransfer_MediatR = 2048 | Apizr_Integrations_MediatR | Apizr_Extensions_Microsoft_FileTransfer,
-
- [Description("dotnet add package Apizr.Integrations.Optional, then register MediatR")]
- Apizr_Integrations_Optional = 4096 | Apizr_Integrations_MediatR,
-
- [Description("dotnet add package Apizr.Integrations.FileTransfer.Optional, then register MediatR")]
- Apizr_Integrations_FileTransfer_Optional = 8192 | Apizr_Integrations_Optional | Apizr_Integrations_FileTransfer_MediatR,
+ Apizr_Integrations_FileTransfer_MediatR = 2048 | Apizr_Integrations_MediatR | Apizr_Extensions_Microsoft_FileTransfer
}
}
diff --git a/src/Refitter.Core/Settings/ApizrSettings.cs b/src/Refitter.Core/Settings/ApizrSettings.cs
index 64c8bcbdc..eda0d302a 100644
--- a/src/Refitter.Core/Settings/ApizrSettings.cs
+++ b/src/Refitter.Core/Settings/ApizrSettings.cs
@@ -1,4 +1,4 @@
-using System.Text.Json.Serialization;
+using System.Text.Json.Serialization;
namespace Refitter.Core
{
@@ -52,11 +52,6 @@ public class ApizrSettings
///
public bool WithMediation { get; set; } = false;
- ///
- /// Set it to true to handle request with MediatR and Optional result (default: false)
- ///
- public bool WithOptionalMediation { get; set; } = false;
-
///
/// Set it to true to manage file transfers (default: false)
///
diff --git a/src/Refitter.SourceGenerator/README.md b/src/Refitter.SourceGenerator/README.md
index 8db155f0b..e15a0dd4f 100644
--- a/src/Refitter.SourceGenerator/README.md
+++ b/src/Refitter.SourceGenerator/README.md
@@ -83,7 +83,6 @@ The following is an example `.refitter` file
"withCacheProvider": "InMemory", // Optional. Values=None|Akavache|MonkeyCache|InMemory|DistributedAsString|DistributedAsByteArray. Default=None
"withPriority": true, // Optional. Default=false
"withMediation": true, // Optional. Default=false
- "withOptionalMediation": true, // Optional. Default=false
"withMappingProvider": "AutoMapper", // Optional. Values=None|AutoMapper|Mapster. Default=None
"withFileTransfer": true // Optional. Default=false
},
@@ -160,7 +159,6 @@ The following is an example `.refitter` file
- `withCacheProvider` - Set the cache provider to be used
- `withPriority` - Tells if Apizr should handle request priority
- `withMediation` - Tells if Apizr should handle request mediation (extended only)
- - `withOptionalMediation` - Tells if Apizr should handle optional request mediation (extended only)
- `withMappingProvider` - Set the mapping provider to be used
- `withFileTransfer` - Tells if Apizr should handle file transfer
- `codeGeneratorSettings` - Setting this allows customization of the NSwag generated types and contracts
@@ -192,4 +190,4 @@ The following is an example `.refitter` file
- `generateNativeRecords` - Default is false
- `generateDefaultValues` - Default is true
- `inlineNamedAny` - Default is false
- - `excludedTypeNames` - Default is empty
\ No newline at end of file
+ - `excludedTypeNames` - Default is empty
diff --git a/src/Refitter.Tests/ApizrGeneratorWithMicrosoftHttpResilienceTests.cs b/src/Refitter.Tests/ApizrGeneratorWithMicrosoftHttpResilienceTests.cs
index d9174aab5..50b1277ad 100644
--- a/src/Refitter.Tests/ApizrGeneratorWithMicrosoftHttpResilienceTests.cs
+++ b/src/Refitter.Tests/ApizrGeneratorWithMicrosoftHttpResilienceTests.cs
@@ -1,4 +1,4 @@
-using FluentAssertions;
+using FluentAssertions;
using Refitter.Core;
using Xunit;
@@ -25,7 +25,6 @@ public class ApizrGeneratorWithMicrosoftHttpResilienceTests
WithCacheProvider = CacheProviderType.InMemory,
WithPriority = true,
WithMediation = true,
- WithOptionalMediation = true,
WithMappingProvider = MappingProviderType.AutoMapper,
WithFileTransfer = true
}
@@ -41,7 +40,6 @@ public class ApizrGeneratorWithMicrosoftHttpResilienceTests
WithCacheProvider = CacheProviderType.InMemory,
WithPriority = true,
WithMediation = true,
- WithOptionalMediation = true,
WithMappingProvider = MappingProviderType.AutoMapper,
WithFileTransfer = true
}
@@ -168,4 +166,4 @@ public void Can_Generate_Static_Registration_For_Multiple_Interfaces()
code.Should().Contain("AddManagerFor()");
}
#endregion
-}
\ No newline at end of file
+}
diff --git a/src/Refitter.Tests/ApizrGeneratorWithPollyTests.cs b/src/Refitter.Tests/ApizrGeneratorWithPollyTests.cs
index e201135db..fe14f89be 100644
--- a/src/Refitter.Tests/ApizrGeneratorWithPollyTests.cs
+++ b/src/Refitter.Tests/ApizrGeneratorWithPollyTests.cs
@@ -1,4 +1,4 @@
-using FluentAssertions;
+using FluentAssertions;
using Refitter.Core;
using Xunit;
@@ -27,7 +27,6 @@ public class ApizrGeneratorWithPollyTests
WithCacheProvider = CacheProviderType.InMemory,
WithPriority = true,
WithMediation = true,
- WithOptionalMediation = true,
WithMappingProvider = MappingProviderType.AutoMapper,
WithFileTransfer = true
}
@@ -124,4 +123,4 @@ public void Can_Generate_Without_BaseUrl()
code.Should().Contain("> optionsBuilder)");
}
-}
\ No newline at end of file
+}
diff --git a/src/Refitter.Tests/Build/ProjectFileContents.cs b/src/Refitter.Tests/Build/ProjectFileContents.cs
index 4e6712e47..a914f200b 100644
--- a/src/Refitter.Tests/Build/ProjectFileContents.cs
+++ b/src/Refitter.Tests/Build/ProjectFileContents.cs
@@ -1,4 +1,4 @@
-namespace Refitter.Tests.Build;
+namespace Refitter.Tests.Build;
public static class ProjectFileContents
{
@@ -8,22 +8,22 @@ public static class ProjectFileContents
net8.0
-
+
-
-
-
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
";
-}
\ No newline at end of file
+}
diff --git a/src/Refitter.Tests/SwaggerPetstoreApizrTests.cs b/src/Refitter.Tests/SwaggerPetstoreApizrTests.cs
index b11b525bb..627a5db6c 100644
--- a/src/Refitter.Tests/SwaggerPetstoreApizrTests.cs
+++ b/src/Refitter.Tests/SwaggerPetstoreApizrTests.cs
@@ -1,4 +1,4 @@
-using FluentAssertions;
+using FluentAssertions;
using Refitter.Core;
using Refitter.Tests.Build;
using Refitter.Tests.Resources;
@@ -24,7 +24,6 @@ public ApizrGeneratorSettings()
WithCacheProvider = CacheProviderType.InMemory,
WithPriority = true,
WithMediation = true,
- WithOptionalMediation = true,
WithMappingProvider = MappingProviderType.AutoMapper,
WithFileTransfer = true
};
@@ -658,4 +657,4 @@ private static async Task GenerateCode(
var sut = await RefitGenerator.CreateAsync(settings);
return sut.Generate();
}
-}
\ No newline at end of file
+}
diff --git a/src/Refitter.Tests/SwaggerPetstoreTests.cs b/src/Refitter.Tests/SwaggerPetstoreTests.cs
index e5ce56c98..9828173e8 100644
--- a/src/Refitter.Tests/SwaggerPetstoreTests.cs
+++ b/src/Refitter.Tests/SwaggerPetstoreTests.cs
@@ -1,4 +1,4 @@
-using FluentAssertions;
+using FluentAssertions;
using Refitter.Core;
using Refitter.Tests.Build;
using Refitter.Tests.Resources;
@@ -372,7 +372,6 @@ public async Task Can_Generate_Code_Apizr_Setup(SampleOpenSpecifications version
WithCacheProvider = CacheProviderType.InMemory,
WithPriority = true,
WithMediation = true,
- WithOptionalMediation = true,
WithMappingProvider = MappingProviderType.AutoMapper,
WithFileTransfer = true
}
@@ -402,7 +401,6 @@ public async Task Can_Generate_Code_Apizr_Setup_With_Polly(SampleOpenSpecificati
WithCacheProvider = CacheProviderType.InMemory,
WithPriority = true,
WithMediation = true,
- WithOptionalMediation = true,
WithMappingProvider = MappingProviderType.AutoMapper,
WithFileTransfer = true
}
@@ -432,7 +430,6 @@ public async Task Can_Generate_Code_Apizr_Setup_Without_Polly(SampleOpenSpecific
WithCacheProvider = CacheProviderType.InMemory,
WithPriority = true,
WithMediation = true,
- WithOptionalMediation = true,
WithMappingProvider = MappingProviderType.AutoMapper,
WithFileTransfer = true
}
@@ -743,4 +740,4 @@ public async Task Can_Generate_Code_With_DynamicQuerystringParameters(SampleOpen
generateCode.Should().Contain("[Query] LoginUserQueryParams queryParams);")
.And.Contain("public class LoginUserQueryParams");
}
-}
\ No newline at end of file
+}
diff --git a/src/Refitter/README.md b/src/Refitter/README.md
index 98deea2c2..d7c6d41f1 100644
--- a/src/Refitter/README.md
+++ b/src/Refitter/README.md
@@ -174,7 +174,6 @@ The following is an example `.refitter` file
"withCacheProvider": "InMemory", // Optional. Values=None|Akavache|MonkeyCache|InMemory|DistributedAsString|DistributedAsByteArray. Default=None
"withPriority": true, // Optional. Default=false
"withMediation": true, // Optional. Default=false
- "withOptionalMediation": true, // Optional. Default=false
"withMappingProvider": "AutoMapper", // Optional. Values=None|AutoMapper|Mapster. Default=None
"withFileTransfer": true // Optional. Default=false
},
@@ -258,7 +257,6 @@ The following is an example `.refitter` file
- `withCacheProvider` - Set the cache provider to be used
- `withPriority` - Tells if Apizr should handle request priority
- `withMediation` - Tells if Apizr should handle request mediation (extended only)
- - `withOptionalMediation` - Tells if Apizr should handle optional request mediation (extended only)
- `withMappingProvider` - Set the mapping provider to be used
- `withFileTransfer` - Tells if Apizr should handle file transfer
- `codeGeneratorSettings` - Setting this allows customization of the NSwag generated types and contracts
@@ -1832,7 +1830,6 @@ This is what the `.refitter` settings file may look like, depending on you confi
"withCacheProvider": "InMemory", // Optional, default is None
"withPriority": true, // Optional, default is false
"withMediation": true, // Optional, default is false
- "withOptionalMediation": true, // Optional, default is false
"withMappingProvider": "AutoMapper", // Optional, default is None
"withFileTransfer": true // Optional, default is false
}
@@ -1863,8 +1860,7 @@ public static IServiceCollection ConfigurePetstoreApiApizrManager(
.WithInMemoryCacheHandler()
.WithAutoMapperMappingHandler()
.WithPriority()
- .WithOptionalMediation()
- .WithFileTransferOptionalMediation();
+ .WithFileTransferMediation();
return services.AddApizrManagerFor(optionsBuilder);
}
@@ -1895,7 +1891,6 @@ This comes in handy especially when generating multiple interfaces, by tag or en
"withCacheProvider": "InMemory", // Optional, default is None
"withPriority": true, // Optional, default is false
"withMediation": true, // Optional, default is false
- "withOptionalMediation": true, // Optional, default is false
"withMappingProvider": "AutoMapper", // Optional, default is None
"withFileTransfer": true // Optional, default is false
}
@@ -1926,8 +1921,7 @@ public static IServiceCollection ConfigurePetstoreApizrManagers(
.WithInMemoryCacheHandler()
.WithAutoMapperMappingHandler()
.WithPriority()
- .WithOptionalMediation()
- .WithFileTransferOptionalMediation();
+ .WithFileTransferMediation();
return services.AddApizr(
registry => registry
@@ -1971,7 +1965,8 @@ public static IApizrManager BuildPetstore30ApizrManag
optionsBuilder += options => options
.WithAkavacheCacheHandler()
.WithAutoMapperMappingHandler(new MapperConfiguration(config => { /* YOUR_MAPPINGS_HERE */ }))
- .WithPriority();
+ .WithPriority()
+ .WithFileTransfer();
return ApizrBuilder.Current.CreateManagerFor(optionsBuilder);
}
@@ -2002,7 +1997,6 @@ This comes in handy especially when generating multiple interfaces, by tag or en
"withCacheProvider": "InMemory", // Optional, default is None
"withPriority": true, // Optional, default is false
"withMediation": true, // Optional, default is false
- "withOptionalMediation": true, // Optional, default is false
"withMappingProvider": "AutoMapper", // Optional, default is None
"withFileTransfer": true // Optional, default is false
}
@@ -2018,7 +2012,8 @@ public static IApizrRegistry BuildPetstoreApizrManagers(Action options
.WithAkavacheCacheHandler()
.WithAutoMapperMappingHandler(new MapperConfiguration(config => { /* YOUR_MAPPINGS_HERE */ }))
- .WithPriority();
+ .WithPriority()
+ .WithFileTransferMediation();
return ApizrBuilder.Current.CreateRegistry(
registry => registry