diff --git a/src/Refitter.Core/ApizrRegistrationGenerator.cs b/src/Refitter.Core/ApizrRegistrationGenerator.cs index 62fe7f7b..a4693320 100644 --- a/src/Refitter.Core/ApizrRegistrationGenerator.cs +++ b/src/Refitter.Core/ApizrRegistrationGenerator.cs @@ -1,7 +1,5 @@ using System.Globalization; using System.Text; -using System.Text.RegularExpressions; - using Refitter.Core.Settings; namespace Refitter.Core; diff --git a/src/Refitter.Core/CSharpClientGeneratorFactory.cs b/src/Refitter.Core/CSharpClientGeneratorFactory.cs index 37ab671d..25a97616 100644 --- a/src/Refitter.Core/CSharpClientGeneratorFactory.cs +++ b/src/Refitter.Core/CSharpClientGeneratorFactory.cs @@ -1,7 +1,6 @@ using System.Reflection; using NJsonSchema.CodeGeneration; using NJsonSchema.CodeGeneration.CSharp; - using NSwag; using NSwag.CodeGeneration.CSharp; diff --git a/src/Refitter.Core/CustomCSharpPropertyNameGenerator.cs b/src/Refitter.Core/CustomCSharpPropertyNameGenerator.cs index 489bf2b0..6d18f4c6 100644 --- a/src/Refitter.Core/CustomCSharpPropertyNameGenerator.cs +++ b/src/Refitter.Core/CustomCSharpPropertyNameGenerator.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; - using NJsonSchema; using NJsonSchema.CodeGeneration; diff --git a/src/Refitter.Core/OpenApiDocumentFactory.cs b/src/Refitter.Core/OpenApiDocumentFactory.cs index 455688de..3a8d283a 100644 --- a/src/Refitter.Core/OpenApiDocumentFactory.cs +++ b/src/Refitter.Core/OpenApiDocumentFactory.cs @@ -1,10 +1,7 @@ using System.Net; - using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Readers; - using NSwag; - using OpenApiDocument = NSwag.OpenApiDocument; namespace Refitter.Core; diff --git a/src/Refitter.Core/OperationNameGenerator.cs b/src/Refitter.Core/OperationNameGenerator.cs index cd41aca8..3b4ac170 100644 --- a/src/Refitter.Core/OperationNameGenerator.cs +++ b/src/Refitter.Core/OperationNameGenerator.cs @@ -1,8 +1,6 @@ -using NSwag; +using System.Diagnostics.CodeAnalysis; +using NSwag; using NSwag.CodeGeneration.OperationNameGenerators; - -using System.Diagnostics.CodeAnalysis; - using GeneratorType = Refitter.Core.OperationNameGeneratorTypes; namespace Refitter.Core; diff --git a/src/Refitter.Core/ParameterExtractor.cs b/src/Refitter.Core/ParameterExtractor.cs index ad63e751..ef771a24 100644 --- a/src/Refitter.Core/ParameterExtractor.cs +++ b/src/Refitter.Core/ParameterExtractor.cs @@ -1,14 +1,8 @@ -using System.Linq; -using System.Text.RegularExpressions; using System.Text; -using System.Xml.Linq; - using NSwag; using NSwag.CodeGeneration.CSharp.Models; using NSwag.CodeGeneration.Models; -using YamlDotNet.Serialization; - namespace Refitter.Core; internal static class ParameterExtractor @@ -53,7 +47,7 @@ public static IEnumerable GetParameters( ? string.Empty : $"[{GetAliasAsAttribute(p)}]"; - return $"{generatedAliasAsAttribute} StreamPart {p.VariableName}"; + return $"{generatedAliasAsAttribute}StreamPart {p.VariableName}"; }) .ToList(); diff --git a/src/Refitter.Core/RefitGenerator.cs b/src/Refitter.Core/RefitGenerator.cs index e00ec63c..90a1e740 100644 --- a/src/Refitter.Core/RefitGenerator.cs +++ b/src/Refitter.Core/RefitGenerator.cs @@ -1,7 +1,6 @@ -using NSwag; - -using System.Text; +using System.Text; using System.Text.RegularExpressions; +using NSwag; namespace Refitter.Core; diff --git a/src/Refitter.Core/RefitInterfaceGenerator.cs b/src/Refitter.Core/RefitInterfaceGenerator.cs index 73d422f4..946a615b 100644 --- a/src/Refitter.Core/RefitInterfaceGenerator.cs +++ b/src/Refitter.Core/RefitInterfaceGenerator.cs @@ -1,6 +1,5 @@ using System.Text; using System.Text.RegularExpressions; - using NSwag; using NSwag.CodeGeneration.CSharp.Models; diff --git a/src/Refitter.Core/RefitInterfaceImports.cs b/src/Refitter.Core/RefitInterfaceImports.cs index d60bf5ec..9be6eb1b 100644 --- a/src/Refitter.Core/RefitInterfaceImports.cs +++ b/src/Refitter.Core/RefitInterfaceImports.cs @@ -1,4 +1,3 @@ -using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Text.RegularExpressions; diff --git a/src/Refitter.Core/RefitMultipleInterfaceByTagGenerator.cs b/src/Refitter.Core/RefitMultipleInterfaceByTagGenerator.cs index 34b3a6d9..80e40ca1 100644 --- a/src/Refitter.Core/RefitMultipleInterfaceByTagGenerator.cs +++ b/src/Refitter.Core/RefitMultipleInterfaceByTagGenerator.cs @@ -1,7 +1,4 @@ -using System.Reflection; -using System.Text; -using System.Xml.Linq; - +using System.Text; using NSwag; namespace Refitter.Core; diff --git a/src/Refitter.Core/RefitMultipleInterfaceGenerator.cs b/src/Refitter.Core/RefitMultipleInterfaceGenerator.cs index 3caaaaa8..4cec857c 100644 --- a/src/Refitter.Core/RefitMultipleInterfaceGenerator.cs +++ b/src/Refitter.Core/RefitMultipleInterfaceGenerator.cs @@ -1,6 +1,4 @@ using System.Text; -using System.Xml.Linq; - using NSwag; namespace Refitter.Core; diff --git a/src/Refitter.Core/SchemaCleaner.cs b/src/Refitter.Core/SchemaCleaner.cs index 4bddef6e..6f134c50 100644 --- a/src/Refitter.Core/SchemaCleaner.cs +++ b/src/Refitter.Core/SchemaCleaner.cs @@ -1,7 +1,5 @@ using System.Text.RegularExpressions; - using NJsonSchema; - using NSwag; namespace Refitter.Core; diff --git a/src/Refitter.Core/Serializer.cs b/src/Refitter.Core/Serializer.cs index 3aa0a9f9..bf609733 100644 --- a/src/Refitter.Core/Serializer.cs +++ b/src/Refitter.Core/Serializer.cs @@ -1,5 +1,4 @@ using System.Text.Json; - using JsonSerializerOptions = System.Text.Json.JsonSerializerOptions; namespace Refitter.Core; diff --git a/src/Refitter.Core/Settings/ApizrPackages.cs b/src/Refitter.Core/Settings/ApizrPackages.cs index de909986..c166d4c3 100644 --- a/src/Refitter.Core/Settings/ApizrPackages.cs +++ b/src/Refitter.Core/Settings/ApizrPackages.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Text; +using System.ComponentModel; namespace Refitter.Core.Settings { diff --git a/src/Refitter.Core/Settings/ApizrSettings.cs b/src/Refitter.Core/Settings/ApizrSettings.cs index 685e3ba9..64c8bcbd 100644 --- a/src/Refitter.Core/Settings/ApizrSettings.cs +++ b/src/Refitter.Core/Settings/ApizrSettings.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Refitter.Core { diff --git a/src/Refitter.Core/XmlDocumentationGenerator.cs b/src/Refitter.Core/XmlDocumentationGenerator.cs index 117a8e9e..95e67fb1 100644 --- a/src/Refitter.Core/XmlDocumentationGenerator.cs +++ b/src/Refitter.Core/XmlDocumentationGenerator.cs @@ -1,5 +1,4 @@ using System.Text; - using NSwag; using NSwag.CodeGeneration.CSharp.Models; diff --git a/src/Refitter.SourceGenerator.Tests/CustomOutputFolderGeneratorTests.cs b/src/Refitter.SourceGenerator.Tests/CustomOutputFolderGeneratorTests.cs index 93ce9927..03f670ab 100644 --- a/src/Refitter.SourceGenerator.Tests/CustomOutputFolderGeneratorTests.cs +++ b/src/Refitter.SourceGenerator.Tests/CustomOutputFolderGeneratorTests.cs @@ -1,9 +1,6 @@ using FluentAssertions; - using Refit; - using Refitter.Tests.CustomGenerated; - using Xunit; namespace Refitter.SourceGenerators.Tests; diff --git a/src/Refitter.SourceGenerator.Tests/DelegatingHandlers.cs b/src/Refitter.SourceGenerator.Tests/DelegatingHandlers.cs index 8ef461ea..c5e6e699 100644 --- a/src/Refitter.SourceGenerator.Tests/DelegatingHandlers.cs +++ b/src/Refitter.SourceGenerator.Tests/DelegatingHandlers.cs @@ -1,8 +1,5 @@ namespace Refitter.Tests.AdditionalFiles.SingeInterface { - using System; - using Microsoft.Extensions.DependencyInjection; - public class EmptyMessageHandler : DelegatingHandler { } diff --git a/src/Refitter.SourceGenerator.Tests/MultipleInterfaceByTagGeneratorTests.cs b/src/Refitter.SourceGenerator.Tests/MultipleInterfaceByTagGeneratorTests.cs index 5b3b9d2c..3fb137ab 100644 --- a/src/Refitter.SourceGenerator.Tests/MultipleInterfaceByTagGeneratorTests.cs +++ b/src/Refitter.SourceGenerator.Tests/MultipleInterfaceByTagGeneratorTests.cs @@ -1,9 +1,6 @@ using FluentAssertions; - using Refit; - using Refitter.Tests.AdditionalFiles.ByTag; - using Xunit; namespace Refitter.SourceGenerators.Tests; diff --git a/src/Refitter.SourceGenerator.Tests/MultipleInterfaceGeneratorTests.cs b/src/Refitter.SourceGenerator.Tests/MultipleInterfaceGeneratorTests.cs index cb79a032..9d3b2da5 100644 --- a/src/Refitter.SourceGenerator.Tests/MultipleInterfaceGeneratorTests.cs +++ b/src/Refitter.SourceGenerator.Tests/MultipleInterfaceGeneratorTests.cs @@ -1,9 +1,6 @@ using FluentAssertions; - using Refit; - using Refitter.Tests.AdditionalFiles.ByEndpoint; - using Xunit; namespace Refitter.SourceGenerators.Tests; diff --git a/src/Refitter.SourceGenerator.Tests/OptionalParametersGeneratorTest.cs b/src/Refitter.SourceGenerator.Tests/OptionalParametersGeneratorTest.cs index 85c3e257..dc338152 100644 --- a/src/Refitter.SourceGenerator.Tests/OptionalParametersGeneratorTest.cs +++ b/src/Refitter.SourceGenerator.Tests/OptionalParametersGeneratorTest.cs @@ -1,9 +1,6 @@ using FluentAssertions; - using Refit; - using Refitter.Tests.AdditionalFiles.OptionalParameters; - using Xunit; namespace Refitter.SourceGenerators.Tests; diff --git a/src/Refitter.SourceGenerator.Tests/SingleInterfaceGeneratorTest.cs b/src/Refitter.SourceGenerator.Tests/SingleInterfaceGeneratorTest.cs index e0d5cc8d..7de77f85 100644 --- a/src/Refitter.SourceGenerator.Tests/SingleInterfaceGeneratorTest.cs +++ b/src/Refitter.SourceGenerator.Tests/SingleInterfaceGeneratorTest.cs @@ -1,9 +1,6 @@ using FluentAssertions; - using Refit; - using Refitter.Tests.AdditionalFiles.SingeInterface; - using Xunit; namespace Refitter.SourceGenerators.Tests; diff --git a/src/Refitter.SourceGenerator.Tests/UseJsonInheritanceConverterTests.cs b/src/Refitter.SourceGenerator.Tests/UseJsonInheritanceConverterTests.cs index 3af2020b..2e580906 100644 --- a/src/Refitter.SourceGenerator.Tests/UseJsonInheritanceConverterTests.cs +++ b/src/Refitter.SourceGenerator.Tests/UseJsonInheritanceConverterTests.cs @@ -1,5 +1,4 @@ using FluentAssertions; - using Refitter.Tests.UseJsonInheritanceConverter; using Xunit; diff --git a/src/Refitter.SourceGenerator.Tests/UsePolymorphicSerializationTests.cs b/src/Refitter.SourceGenerator.Tests/UsePolymorphicSerializationTests.cs index e555ffbe..b2eccb3b 100644 --- a/src/Refitter.SourceGenerator.Tests/UsePolymorphicSerializationTests.cs +++ b/src/Refitter.SourceGenerator.Tests/UsePolymorphicSerializationTests.cs @@ -1,8 +1,6 @@ using System.Text.Json.Serialization; using FluentAssertions; - using Refitter.Tests.UsePolymorphicSerialization; - using Xunit; namespace Refitter.SourceGenerators.Tests; diff --git a/src/Refitter.SourceGenerator/RefitterSourceGenerator.cs b/src/Refitter.SourceGenerator/RefitterSourceGenerator.cs index 8a14e0a1..34bf78e8 100644 --- a/src/Refitter.SourceGenerator/RefitterSourceGenerator.cs +++ b/src/Refitter.SourceGenerator/RefitterSourceGenerator.cs @@ -1,8 +1,6 @@ using System.Diagnostics.CodeAnalysis; using System.Text; - using Microsoft.CodeAnalysis; - using Refitter.Core; namespace Refitter.SourceGenerator; diff --git a/src/Refitter.Tests/ApizrGeneratorWithMicrosoftHttpResilienceTests.cs b/src/Refitter.Tests/ApizrGeneratorWithMicrosoftHttpResilienceTests.cs index 4558d4ff..d9174aab 100644 --- a/src/Refitter.Tests/ApizrGeneratorWithMicrosoftHttpResilienceTests.cs +++ b/src/Refitter.Tests/ApizrGeneratorWithMicrosoftHttpResilienceTests.cs @@ -1,7 +1,5 @@ using FluentAssertions; - using Refitter.Core; - using Xunit; namespace Refitter.Tests; diff --git a/src/Refitter.Tests/ApizrGeneratorWithPollyTests.cs b/src/Refitter.Tests/ApizrGeneratorWithPollyTests.cs index 6504fa81..e201135d 100644 --- a/src/Refitter.Tests/ApizrGeneratorWithPollyTests.cs +++ b/src/Refitter.Tests/ApizrGeneratorWithPollyTests.cs @@ -1,7 +1,5 @@ using FluentAssertions; - using Refitter.Core; - using Xunit; namespace Refitter.Tests; diff --git a/src/Refitter.Tests/Build/ProjectFileContents.cs b/src/Refitter.Tests/Build/ProjectFileContents.cs index 12d50a1a..3bcab7b2 100644 --- a/src/Refitter.Tests/Build/ProjectFileContents.cs +++ b/src/Refitter.Tests/Build/ProjectFileContents.cs @@ -12,7 +12,7 @@ public static class ProjectFileContents - + diff --git a/src/Refitter.Tests/CustomCSharpGeneratorSettingsTests.cs b/src/Refitter.Tests/CustomCSharpGeneratorSettingsTests.cs index fe294a1b..9d6ca210 100644 --- a/src/Refitter.Tests/CustomCSharpGeneratorSettingsTests.cs +++ b/src/Refitter.Tests/CustomCSharpGeneratorSettingsTests.cs @@ -1,15 +1,7 @@ -using System.Dynamic; -using System.Text.Json; - using Atc.Test; - using FluentAssertions; - -using NJsonSchema.CodeGeneration.CSharp; - using Refitter.Core; using Refitter.Tests.Resources; - using Xunit; namespace Refitter.Tests; diff --git a/src/Refitter.Tests/DependencyInjectionGeneratorWithMicrosoftHttpResilienceTests.cs b/src/Refitter.Tests/DependencyInjectionGeneratorWithMicrosoftHttpResilienceTests.cs index 29c0fb70..4f0dfa61 100644 --- a/src/Refitter.Tests/DependencyInjectionGeneratorWithMicrosoftHttpResilienceTests.cs +++ b/src/Refitter.Tests/DependencyInjectionGeneratorWithMicrosoftHttpResilienceTests.cs @@ -1,7 +1,5 @@ using FluentAssertions; - using Refitter.Core; - using Xunit; namespace Refitter.Tests; diff --git a/src/Refitter.Tests/DependencyInjectionGeneratorWithPollyTests.cs b/src/Refitter.Tests/DependencyInjectionGeneratorWithPollyTests.cs index ac9a7111..0e54a766 100644 --- a/src/Refitter.Tests/DependencyInjectionGeneratorWithPollyTests.cs +++ b/src/Refitter.Tests/DependencyInjectionGeneratorWithPollyTests.cs @@ -1,7 +1,5 @@ using FluentAssertions; - using Refitter.Core; - using Xunit; namespace Refitter.Tests; diff --git a/src/Refitter.Tests/Examples/ApizrTests.cs b/src/Refitter.Tests/Examples/ApizrTests.cs index 01f166d0..a02d56a5 100644 --- a/src/Refitter.Tests/Examples/ApizrTests.cs +++ b/src/Refitter.Tests/Examples/ApizrTests.cs @@ -1,8 +1,6 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Build; - using Xunit; namespace Refitter.Tests.Examples; diff --git a/src/Refitter.Tests/Examples/CaseSensitiveParametersTests.cs b/src/Refitter.Tests/Examples/CaseSensitiveParametersTests.cs index 52f77615..7d62c8e6 100644 --- a/src/Refitter.Tests/Examples/CaseSensitiveParametersTests.cs +++ b/src/Refitter.Tests/Examples/CaseSensitiveParametersTests.cs @@ -1,8 +1,6 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Build; - using Xunit; namespace Refitter.Tests.Examples; diff --git a/src/Refitter.Tests/Examples/CustomCodeGeneratorWithDateTimeTests.cs b/src/Refitter.Tests/Examples/CustomCodeGeneratorWithDateTimeTests.cs index 657ae446..a6074265 100644 --- a/src/Refitter.Tests/Examples/CustomCodeGeneratorWithDateTimeTests.cs +++ b/src/Refitter.Tests/Examples/CustomCodeGeneratorWithDateTimeTests.cs @@ -1,8 +1,6 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Build; - using Xunit; namespace Refitter.Tests.Examples; diff --git a/src/Refitter.Tests/Examples/DeprecatedEndpointTests.cs b/src/Refitter.Tests/Examples/DeprecatedEndpointTests.cs index 50e6157f..427dc9c7 100644 --- a/src/Refitter.Tests/Examples/DeprecatedEndpointTests.cs +++ b/src/Refitter.Tests/Examples/DeprecatedEndpointTests.cs @@ -1,8 +1,6 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Build; - using Xunit; namespace Refitter.Tests.Examples; diff --git a/src/Refitter.Tests/Examples/DeprecatedEndpointsSkippedTests.cs b/src/Refitter.Tests/Examples/DeprecatedEndpointsSkippedTests.cs index b149a12f..6acb3a8c 100644 --- a/src/Refitter.Tests/Examples/DeprecatedEndpointsSkippedTests.cs +++ b/src/Refitter.Tests/Examples/DeprecatedEndpointsSkippedTests.cs @@ -1,8 +1,6 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Build; - using Xunit; namespace Refitter.Tests.Examples; diff --git a/src/Refitter.Tests/Examples/DeprecatedMultipleInterfaceByTagEndpointsSkippedTests.cs b/src/Refitter.Tests/Examples/DeprecatedMultipleInterfaceByTagEndpointsSkippedTests.cs index 0157ca81..76f82d3b 100644 --- a/src/Refitter.Tests/Examples/DeprecatedMultipleInterfaceByTagEndpointsSkippedTests.cs +++ b/src/Refitter.Tests/Examples/DeprecatedMultipleInterfaceByTagEndpointsSkippedTests.cs @@ -1,8 +1,6 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Build; - using Xunit; namespace Refitter.Tests.Examples; diff --git a/src/Refitter.Tests/Examples/DeprecatedMultipleInterfaceEndpointsSkippedTests.cs b/src/Refitter.Tests/Examples/DeprecatedMultipleInterfaceEndpointsSkippedTests.cs index ce3947ea..5ccd36c7 100644 --- a/src/Refitter.Tests/Examples/DeprecatedMultipleInterfaceEndpointsSkippedTests.cs +++ b/src/Refitter.Tests/Examples/DeprecatedMultipleInterfaceEndpointsSkippedTests.cs @@ -1,8 +1,6 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Build; - using Xunit; namespace Refitter.Tests.Examples; diff --git a/src/Refitter.Tests/Examples/FilterByPathTests.cs b/src/Refitter.Tests/Examples/FilterByPathTests.cs index 93501e84..aa963974 100644 --- a/src/Refitter.Tests/Examples/FilterByPathTests.cs +++ b/src/Refitter.Tests/Examples/FilterByPathTests.cs @@ -1,8 +1,6 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Build; - using Xunit; namespace Refitter.Tests.Examples; diff --git a/src/Refitter.Tests/Examples/FilterByTagsTests.cs b/src/Refitter.Tests/Examples/FilterByTagsTests.cs index 01d01383..13ea1267 100644 --- a/src/Refitter.Tests/Examples/FilterByTagsTests.cs +++ b/src/Refitter.Tests/Examples/FilterByTagsTests.cs @@ -1,8 +1,6 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Build; - using Xunit; namespace Refitter.Tests.Examples; diff --git a/src/Refitter.Tests/Examples/KeepSchemaPatternsTests.cs b/src/Refitter.Tests/Examples/KeepSchemaPatternsTests.cs index 42f8267d..4c058f2d 100644 --- a/src/Refitter.Tests/Examples/KeepSchemaPatternsTests.cs +++ b/src/Refitter.Tests/Examples/KeepSchemaPatternsTests.cs @@ -1,8 +1,6 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Build; - using Xunit; namespace Refitter.Tests.Examples; diff --git a/src/Refitter.Tests/Examples/MultiPartFormDataAliasAsTests.cs b/src/Refitter.Tests/Examples/MultiPartFormDataAliasAsTests.cs new file mode 100644 index 00000000..c4a47c43 --- /dev/null +++ b/src/Refitter.Tests/Examples/MultiPartFormDataAliasAsTests.cs @@ -0,0 +1,156 @@ +using FluentAssertions; + +using Refitter.Core; +using Refitter.Tests.Build; + +using Xunit; + +namespace Refitter.Tests.Examples; + +public class MultiPartFormDataAliasAsTests +{ + private const string OpenApiSpec = @" +{ + ""openapi"": ""3.0.1"", + ""paths"": { + ""/animals"": { + ""post"": { + ""tags"": [ + ""Animals"" + ], + ""requestBody"": { + ""content"": { + ""multipart/form-data"": { + ""schema"": { + ""type"": ""object"", + ""properties"": { + ""Name"": { + ""type"": ""string"" + }, + ""AnimalClassFile"": { + ""type"": ""string"", + ""format"": ""binary"" + }, + ""AnimalCrowdFile"": { + ""type"": ""string"", + ""format"": ""binary"" + } + } + }, + ""encoding"": { + ""Name"": { + ""style"": ""form"" + }, + ""AnimalClassFile"": { + ""style"": ""form"" + }, + ""AnimalCrowdFile"": { + ""style"": ""form"" + } + } + } + } + }, + ""responses"": { + ""201"": { + ""description"": ""Created"", + ""content"": { + ""application/json"": { + ""schema"": { + ""$ref"": ""#/components/schemas/AnimalResponse"" + } + } + } + } + } + } + } + }, + ""components"": { + ""schemas"": { + ""AnimalResponse"": { + ""type"": ""object"", + ""properties"": { + ""id"": { + ""type"": ""string"", + ""format"": ""uuid"", + ""nullable"": true + }, + ""Name"": { + ""type"": ""string"", + ""nullable"": true + }, + ""AnimalClassFileUri"": { + ""type"": ""string"", + ""nullable"": true + }, + ""AnimalCrowdFileUri"": { + ""type"": ""string"", + ""nullable"": true + } + }, + ""additionalProperties"": false + } + } + } +} +"; + + [Fact] + public async Task Can_Generate_Code() + { + string generateCode = await GenerateCode(); + generateCode.Should().NotBeNullOrWhiteSpace(); + } + + [Fact] + public async Task Can_Build_Generated_Code() + { + string generateCode = await GenerateCode(); + BuildHelper + .BuildCSharp(generateCode) + .Should() + .BeTrue(); + } + + [Fact] + public async Task Generated_Code_Contains_MultiPart_Attribute() + { + string generateCode = await GenerateCode(); + generateCode.Should().Contain("[Multipart]"); + } + + [Fact] + public async Task Generated_Code_Contains_AliasAs_Attribute() + { + string generateCode = await GenerateCode(); + generateCode.Should().Contain("[AliasAs(\"AnimalClassFile\")]"); + } + + [Fact] + public async Task Generated_Code_Contains_StreamPart_Parameter() + { + string generateCode = await GenerateCode(); + generateCode.Should().Contain("StreamPart"); + } + + private static async Task GenerateCode() + { + var swaggerFile = await CreateSwaggerFile(OpenApiSpec); + var settings = new RefitGeneratorSettings { OpenApiPath = swaggerFile }; + + var sut = await RefitGenerator.CreateAsync(settings); + var generateCode = sut.Generate(); + return generateCode; + } + + private static async Task CreateSwaggerFile(string contents) + { + var filename = $"{Guid.NewGuid()}.json"; + var folder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); + Directory.CreateDirectory(folder); + var swaggerFile = Path.Combine(folder, filename); + await File.WriteAllTextAsync(swaggerFile, contents); + return swaggerFile; + } +} \ No newline at end of file diff --git a/src/Refitter.Tests/Examples/MultiPartFormDataTests.cs b/src/Refitter.Tests/Examples/MultiPartFormDataTests.cs index 8562390d..5fa2888f 100644 --- a/src/Refitter.Tests/Examples/MultiPartFormDataTests.cs +++ b/src/Refitter.Tests/Examples/MultiPartFormDataTests.cs @@ -1,8 +1,6 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Build; - using Xunit; namespace Refitter.Tests.Examples; diff --git a/src/Refitter.Tests/Examples/OptionalNullableParametersTests.cs b/src/Refitter.Tests/Examples/OptionalNullableParametersTests.cs index d72374f1..54f96258 100644 --- a/src/Refitter.Tests/Examples/OptionalNullableParametersTests.cs +++ b/src/Refitter.Tests/Examples/OptionalNullableParametersTests.cs @@ -1,8 +1,6 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Build; - using Xunit; namespace Refitter.Tests.Examples; diff --git a/src/Refitter.Tests/Examples/TrimUnusedSchemaTests.cs b/src/Refitter.Tests/Examples/TrimUnusedSchemaTests.cs index b1e0a07e..592575f7 100644 --- a/src/Refitter.Tests/Examples/TrimUnusedSchemaTests.cs +++ b/src/Refitter.Tests/Examples/TrimUnusedSchemaTests.cs @@ -1,8 +1,6 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Build; - using Xunit; namespace Refitter.Tests.Examples; diff --git a/src/Refitter.Tests/Examples/UsePolymorphicSerializationTests.cs b/src/Refitter.Tests/Examples/UsePolymorphicSerializationTests.cs index 086749a0..8df8d6ce 100644 --- a/src/Refitter.Tests/Examples/UsePolymorphicSerializationTests.cs +++ b/src/Refitter.Tests/Examples/UsePolymorphicSerializationTests.cs @@ -1,8 +1,6 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Build; - using Xunit; namespace Refitter.Tests.Examples; diff --git a/src/Refitter.Tests/IllegalSymbolsTests.cs b/src/Refitter.Tests/IllegalSymbolsTests.cs index f4ce4f44..f8d1f74e 100644 --- a/src/Refitter.Tests/IllegalSymbolsTests.cs +++ b/src/Refitter.Tests/IllegalSymbolsTests.cs @@ -1,9 +1,7 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Build; using Refitter.Tests.Resources; - using Xunit; namespace Refitter.Tests; diff --git a/src/Refitter.Tests/OpenApiDocumentFactoryTests.cs b/src/Refitter.Tests/OpenApiDocumentFactoryTests.cs index 26827a57..c2787d4c 100644 --- a/src/Refitter.Tests/OpenApiDocumentFactoryTests.cs +++ b/src/Refitter.Tests/OpenApiDocumentFactoryTests.cs @@ -1,8 +1,6 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Resources; - using Xunit; namespace Refitter.Tests; diff --git a/src/Refitter.Tests/SerializerTests.cs b/src/Refitter.Tests/SerializerTests.cs index fee8288d..7cd61edf 100644 --- a/src/Refitter.Tests/SerializerTests.cs +++ b/src/Refitter.Tests/SerializerTests.cs @@ -1,13 +1,6 @@ -using System.Diagnostics; -using System.Reflection; -using System.Text.Json; - -using Atc.Test; - +using Atc.Test; using FluentAssertions; - using Refitter.Core; - using Xunit; namespace Refitter.Tests; diff --git a/src/Refitter.Tests/SwaggerPetstoreApizrTests.cs b/src/Refitter.Tests/SwaggerPetstoreApizrTests.cs index d15737a3..b11b525b 100644 --- a/src/Refitter.Tests/SwaggerPetstoreApizrTests.cs +++ b/src/Refitter.Tests/SwaggerPetstoreApizrTests.cs @@ -1,10 +1,7 @@ using FluentAssertions; -using FluentAssertions.Equivalency; - using Refitter.Core; using Refitter.Tests.Build; using Refitter.Tests.Resources; - using Xunit; namespace Refitter.Tests; diff --git a/src/Refitter.Tests/SwaggerPetstoreTests.cs b/src/Refitter.Tests/SwaggerPetstoreTests.cs index a3c2945e..e5ce56c9 100644 --- a/src/Refitter.Tests/SwaggerPetstoreTests.cs +++ b/src/Refitter.Tests/SwaggerPetstoreTests.cs @@ -1,9 +1,7 @@ using FluentAssertions; - using Refitter.Core; using Refitter.Tests.Build; using Refitter.Tests.Resources; - using Xunit; namespace Refitter.Tests; diff --git a/src/Refitter.Tests/XmlDocumentationGeneratorTests.cs b/src/Refitter.Tests/XmlDocumentationGeneratorTests.cs index 9b382141..4eb81a68 100644 --- a/src/Refitter.Tests/XmlDocumentationGeneratorTests.cs +++ b/src/Refitter.Tests/XmlDocumentationGeneratorTests.cs @@ -1,12 +1,8 @@ using System.Text; - using FluentAssertions; - using NSwag; using NSwag.CodeGeneration.CSharp.Models; - using Refitter.Core; - using Xunit; namespace Refitter.Tests diff --git a/src/Refitter/Analytics.cs b/src/Refitter/Analytics.cs index 81ccd523..7b1a4e6e 100644 --- a/src/Refitter/Analytics.cs +++ b/src/Refitter/Analytics.cs @@ -1,10 +1,7 @@ using System.Reflection; -using System.Text.Json; using Exceptionless; using Exceptionless.Plugins; - using Refitter.Core; - using Spectre.Console.Cli; namespace Refitter; diff --git a/src/Refitter/GenerateCommand.cs b/src/Refitter/GenerateCommand.cs index 04475500..ea5131b9 100644 --- a/src/Refitter/GenerateCommand.cs +++ b/src/Refitter/GenerateCommand.cs @@ -1,11 +1,8 @@ using System.Diagnostics; - using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.Exceptions; - using Refitter.Core; using Refitter.Validation; - using Spectre.Console; using Spectre.Console.Cli; diff --git a/src/Refitter/Program.cs b/src/Refitter/Program.cs index 68829620..9a020ae5 100644 --- a/src/Refitter/Program.cs +++ b/src/Refitter/Program.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; - using Spectre.Console.Cli; namespace Refitter; diff --git a/src/Refitter/Settings.cs b/src/Refitter/Settings.cs index 8f2255b1..f3bdcc56 100644 --- a/src/Refitter/Settings.cs +++ b/src/Refitter/Settings.cs @@ -1,7 +1,5 @@ using System.ComponentModel; - using Refitter.Core; - using Spectre.Console.Cli; namespace Refitter; diff --git a/src/Refitter/SettingsValidator.cs b/src/Refitter/SettingsValidator.cs index 4f0df347..de723b62 100644 --- a/src/Refitter/SettingsValidator.cs +++ b/src/Refitter/SettingsValidator.cs @@ -1,5 +1,4 @@ using Refitter.Core; - using Spectre.Console; namespace Refitter; diff --git a/src/Refitter/Validation/OpenApiValidationException.cs b/src/Refitter/Validation/OpenApiValidationException.cs index affea498..65642847 100644 --- a/src/Refitter/Validation/OpenApiValidationException.cs +++ b/src/Refitter/Validation/OpenApiValidationException.cs @@ -1,6 +1,4 @@ -using System.Runtime.Serialization; - -namespace Refitter.Validation; +namespace Refitter.Validation; public class OpenApiValidationException : Exception { diff --git a/src/Refitter/Validation/OpenApiValidator.cs b/src/Refitter/Validation/OpenApiValidator.cs index 4b19fc2e..9b1029ff 100644 --- a/src/Refitter/Validation/OpenApiValidator.cs +++ b/src/Refitter/Validation/OpenApiValidator.cs @@ -1,7 +1,4 @@ -using System.Net; -using System.Security; - -using Microsoft.OpenApi.Readers; +using Microsoft.OpenApi.Readers; using Microsoft.OpenApi.Services; namespace Refitter.Validation; diff --git a/test/Apizr/Sample.csproj b/test/Apizr/Sample.csproj index 3268112a..afbad8f8 100644 --- a/test/Apizr/Sample.csproj +++ b/test/Apizr/Sample.csproj @@ -12,7 +12,7 @@ - +