diff --git a/Fonlow.OpenApiClientGen.CS/ControllersClientApiGen.cs b/Fonlow.OpenApiClientGen.CS/ControllersClientApiGen.cs index b827d20f..0c32973b 100644 --- a/Fonlow.OpenApiClientGen.CS/ControllersClientApiGen.cs +++ b/Fonlow.OpenApiClientGen.CS/ControllersClientApiGen.cs @@ -98,7 +98,7 @@ void GenerateCodesToWriter(TextWriter textWriter) string s = streamReader.ReadToEnd(); if (settings.UseEnsureSuccessStatusCodeEx && settings.IncludeEnsureSuccessStatusCodeExBlock) { - textWriter.Write(s.Replace("//;", "").Replace(dummyBlock, blockOfEnsureSuccessStatusCodeEx)); + textWriter.Write(s.Replace("//;", "").Replace(dummyBlock, System.OperatingSystem.IsWindows()? blockOfEnsureSuccessStatusCodeEx : GetBlockOfEnsureSuccessStatusCodeExForLinux())); } else { @@ -315,6 +315,14 @@ void CreateDummyOfEnsureSuccessStatusCodeEx() codeCompileUnit.Namespaces.Add(new CodeNamespace("ZZZzzzEnsureSuccessStatusCodeExDummy")); } + string GetBlockOfEnsureSuccessStatusCodeExForLinux() + { + return blockOfEnsureSuccessStatusCodeEx.ReplaceLineEndings(); + } + + /// + /// Code block for Windows with \r\n + /// const string blockOfEnsureSuccessStatusCodeEx = @" diff --git a/Tests/SwagApiTests/appsettings.json b/Tests/SwagApiTests/appsettings.json index dc23be51..136bf797 100644 --- a/Tests/SwagApiTests/appsettings.json +++ b/Tests/SwagApiTests/appsettings.json @@ -5,7 +5,7 @@ "CommandPath": "dotnet", "Arguments": "run --no-build --configuration Release --project ../../../../../PetWebApi/PetWebApi.csproj", "BaseUrl": "http://127.0.0.1:5000/", - "Delay": 3 + "Delay": 5 } ] } diff --git a/Tests/SwagApiTestsTextJson/appsettings.json b/Tests/SwagApiTestsTextJson/appsettings.json index a7cd396d..64d49d55 100644 --- a/Tests/SwagApiTestsTextJson/appsettings.json +++ b/Tests/SwagApiTestsTextJson/appsettings.json @@ -5,7 +5,7 @@ "CommandPath": "dotnet", "Arguments": "run --no-build --configuration Release --project ../../../../../PetWebApi/PetWebApi.csproj --launch-profile PetWebApiForTextJson", "BaseUrl": "http://127.0.0.1:6000/", - "Delay": 3 + "Delay": 5 } ] }